Example #1
0
def login():
    json_data = request.get_json()
    try:
        user = User.get(username=json_data.get('username'))
    except User.DoesNotExist:
        return error((211, 'Could not find user'))
    if not user.verify_password(json_data.get('password')):
        return error((210, 'The username and password mismatch.'))
    login_user(user)
    return ok(dump_user(user))
Example #2
0
def login():
    json_data = request.get_json()
    try:
        user = User.get(
            username=json_data.get('username'))
    except User.DoesNotExist:
        return error((211, 'Could not find user'))
    if not user.verify_password(json_data.get('password')):
        return error((210, 'The username and password mismatch.'))
    login_user(user)
    return ok(dump_user(user))
Example #3
0
def load_user(userid):
    return User.get(User.id == userid)