feature: 初始化 jwt 插件

This commit is contained in:
zhengxinonly
2023-09-30 16:19:07 +08:00
parent bdd766d2b2
commit 8765b2c344
3 changed files with 21 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
from flask_jwt_extended import JWTManager
from pear_admin.orms.user import UserORM
jwt = JWTManager()
@jwt.user_identity_loader
def user_identity_lookup(user):
return user.id
@jwt.user_lookup_loader
def user_lookup_callback(_jwt_header, jwt_data):
identity = jwt_data["sub"]
return UserORM.query.filter_by(id=identity).one_or_none()