コード例 #1
0
def change_user_password(token, body):
    """
    Verifies token is valid, and updates user password
    :param token: jwt token
    :return:
    """
    try:
        decoded = User.decode_token(token)
        uid = decoded.get('sub')
        password = body['password']
        user = User.query.filter_by(id=uid).first()
        user.update_password(password)

        return 'Password updated', 200
    except Exception as e:
        response = jsonify({'message': str(e)})
        return response, 401
コード例 #2
0
def reset_password_verifier(token):
    """
    Verifies token from url path (client side) is valid
    :param token: jwt token
    :return:
    """
    try:
        decoded = User.decode_token(token)
        uid = decoded.get('sub')
        user = User.query.filter_by(id=uid).first()
        results = {
            'uid': uid,
            'message': 'Token verified',
        }
        return results, 200
    except Exception as e:
        response = jsonify({'message': str(e)})
        return response, 401