def get_users():
    print("get_users")
    content = request.get_json()
    if content is None:
        return json_response.get_error_msg('Invalid request')
    print(content)
    request_user_id = content.get('user_id')
    result = admin.find_users(request_user_id)
    if isinstance(result, dict) or isinstance(result, list):
        return json_response.get_success_data(result)
    else:
        return json_response.get_error_msg(result)
Пример #2
0
def check_youmeng():
    print("check_youmeng")
    content = request.get_json()
    if content is None:
        return json_response.get_error_msg('Invalid request')
    print(content)
    request_id = content.get('id')
    baidu = content.get('youmeng_baidu')
    google = content.get('youmeng_google')
    sougou = content.get('youmeng_sougou')
    taobao = content.get('youmeng_taobao')
    result = auth.check_youmeng(request_id, baidu, google, sougou, taobao)
    if isinstance(result, dict):
        return json_response.get_success_data(result)
    elif isinstance(result, str):
        return json_response.get_error_msg(result)
    else:
        return json_response.get_error_msg(result)
Пример #3
0
def login():
    print("login")
    content = request.get_json()
    if content is None:
        return json_response.get_error_msg('Invalid request')
    print(content)
    name = content.get('name')
    password = content.get('password')
    check_result = check_params(name, password, check_password=False)
    if check_result is not None:
        return check_result
    result = auth.login(name, password)
    if isinstance(result, dict):
        log.add_log(result['id'], 'login', content.get('ip'),
                    content.get('location'))
        return json_response.get_success_data(data=result,
                                              message='Login Success')
    else:
        return json_response.get_error_msg(result)
Пример #4
0
def register():
    print("register")
    content = request.get_json()
    if content is None:
        return json_response.get_error_msg('Invalid request')
    name = content.get('name')
    password = content.get('password')
    im_qq = content.get('im_qq')
    alipay = content.get('alipay')
    alipay_name = content.get('alipay_name')

    check_result = check_params(name, password)
    if check_result is not None:
        return check_result

    if string_utils.is_empty(im_qq):
        return json_response.get_error_msg('Invalid im_qq')
    if string_utils.is_empty(alipay):
        return json_response.get_error_msg('Invalid alipay')
    if string_utils.is_empty(alipay_name):
        return json_response.get_error_msg('Invalid alipay_name')

    result = auth.find_user(request_name=name)
    if result is not None:
        return json_response.get_error_msg(
            'This name [' + name +
            ']  has been registered yet, please login or change another name.')

    result = auth.register(name, password, im_qq, alipay, alipay_name)
    if isinstance(result, dict):
        log.add_log(result['id'], 'register', content.get('ip'),
                    content.get('location'))
        return json_response.get_success_data(data=result,
                                              message='Register successfully!')
    else:
        return json_response.get_error_msg(result)