auth.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:zimfarm 作者: openzim 项目源码 文件源码
def login():
    username = request.headers.get('username')
    password = request.headers.get('password')

    if username is None or password is None:
        raise InvalidRequest()

    user = UsersCollection().find_one({'username': username})
    if user is None:
        raise AuthFailed()

    is_valid = check_password_hash(user['password_hash'], password)
    if not is_valid:
        raise AuthFailed()

    return jsonify({'token': UserJWT.new(username, user['scope'])})
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号