feature: 登录&权限拦截

This commit is contained in:
zhengxinonly
2023-10-01 23:42:59 +08:00
parent 8765b2c344
commit 69a4955ce2
6 changed files with 86 additions and 46 deletions
+11
View File
@@ -1,3 +1,4 @@
from flask import redirect
from flask_jwt_extended import JWTManager
from pear_admin.orms.user import UserORM
@@ -14,3 +15,13 @@ def user_identity_lookup(user):
def user_lookup_callback(_jwt_header, jwt_data):
identity = jwt_data["sub"]
return UserORM.query.filter_by(id=identity).one_or_none()
@jwt.expired_token_loader
def expired_token_callback():
return redirect("/login")
@jwt.unauthorized_loader
def missing_token_callback(error):
return redirect("/login")