Exemplo n.º 1
0
def user_bind():
    verify_code = int(request_value(request, 'code'))
    pwd = request_value(request, 'pwd')
    email = request_value(request, 'email').strip()
    username = request_value(request, 'username').strip()

    auth, user_id, pass_email, auth_username = RGUIController.do_auth_more_info(
        need_request_email=False)
    if not auth or username != auth_username:
        return jsonify(form_res(RGResCode.auth_fail))

    uid, res = user.verify_user(username=username,
                                email=email,
                                pwd=pwd,
                                verify_code=verify_code,
                                verify_type=RGVerifyType.bind)

    if uid is not None:
        token = RGUIController.token_session(uid=uid,
                                             token_type=session['type'],
                                             username=username,
                                             email=email,
                                             remember=None)
        return jsonify(form_res(RGResCode.ok, {'token': token}))
    else:
        return jsonify(form_res(res, None))
Exemplo n.º 2
0
def user_password():
    username = request_value(request, 'username')
    if username is not None:
        username = username.strip()

    pwd = request_value(request, 'pwd')
    verify_code = int(request_value(request, 'code', default='0'))

    uid, res = user.verify_user(username=username,
                                email=None,
                                pwd=pwd,
                                verify_code=verify_code,
                                verify_type=RGVerifyType.forget_pwd)

    if uid is not None:
        _user = user.get_user_with_username(username=username, need_email=True)
        remember = int(request_value(request, 'remember', default='0'))
        token_type = int(request_value(request, 'type', default='0'))
        token = RGUIController.token_session(uid=uid,
                                             token_type=token_type,
                                             username=username,
                                             email=_user.email,
                                             remember=remember)
        return jsonify(form_res(RGResCode.ok, {'token': token}))
    else:
        return jsonify(form_res(res, None))
Exemplo n.º 3
0
def user_login():
    username = request_value(request, 'username').strip()
    pwd = request_value(request, 'pwd')
    _user = user.user_login(username, pwd)

    remember = int(request_value(request, 'remember', default='0'))
    token_type = int(request_value(request, 'type', default='0'))

    if _user is not None:
        token = RGUIController.token_session(uid=_user.ID,
                                             token_type=token_type,
                                             username=_user.username,
                                             email=_user.email,
                                             remember=remember)
        resp = jsonify(form_res(RGResCode.ok, {'token': token}))
        return resp
    else:
        return jsonify(form_res(RGResCode.not_existed, None))