예제 #1
0
def register_user(user_id, password, ip, email, nickname, realname, career,
                  address, over18):
    url = cfg.config.get('ptt_server', '') + '/register'

    params = {
        'UserID': user_id,
        'Passwd': password,
        'IP': ip,
        'Email': email,
        'Nickname': nickname,
        'Realname': realname,
        'Career': career,
        'Address': address,
        'Over18': over18,
    }
    err, result = http_post(url, params)
    if err is not None:
        return err, result

    jwt = result.get('Jwt', '')

    pyutil_mongo.db_update('user', {'user_id': user_id}, {
        'jwt': jwt,
        'active': True,
        'last_login': get_current_milli_ts()
    })

    return None, jwt
예제 #2
0
def find_board_by_name(params):
    '''

    Args:
        params (TYPE): Description

    Returns:
        TYPE: Description
    '''
    keyword = params.get('name', '')
    start_idx = params.get('startIdx', '')
    err, the_max = _int(params.get('max', MAX_LIST))
    if err:
        return err, {}

    if the_max >= MAX_LIST:
        the_max = MAX_LIST

    url = cfg.config.get('ptt_server', '') + LOAD_GENERAL_BOARDS

    # serialize params
    data = {
        'start_idx': start_idx,
        'max': the_max,
        'keyword': keyword,
    }
    err, http_results = http_post(url, data)
    if err:
        return err, {}

    err, results = deserialize_board_list(http_results)
    if err:
        return err, {}

    return None, results
예제 #3
0
def validate_user(user_id, password, ip):
    url = cfg.config.get('ptt_server', '') + '/login'
    err, result = http_post(url, {
        'UserID': user_id,
        'Passwd': password,
        "IP": ip
    })
    if err is not None:
        return err, ''

    jwt = result.get('Jwt', '')

    pyutil_mongo.db_update('user', {'user_id': user_id}, {
        'jwt': jwt,
        'active': True,
        'last_login': get_current_milli_ts()
    })

    return None, jwt
def validate_user(user_id, password):
    """validate user

    Args:
        user_id (TYPE): Description
        password (TYPE): Description

    Returns:
        TYPE: Description
    """
    url = cfg.config.get('ptt_server', '') + LOGIN

    err, result = http_post(url, {'username': user_id, 'password': password})

    if err:
        return err, ''

    jwt = result.get('access_token', '')

    return None, jwt
def register_user(user_id, password, email, nickname, realname, career, address, over18):
    url = cfg.config.get('ptt_server', '') + REGISTER

    params = {
        'username': user_id,
        'password': password,

        'email': email,
        'nickname': nickname,
        'realname': realname,
        'career': career,
        'address': address,
        'over18': over18,
    }
    err, result = http_post(url, params)
    if err:
        return err, result.get('err', '')

    jwt = result.get('access_token', '')

    return None, jwt