diff --git a/backend/common/context.py b/backend/common/context.py index 2b06d0a4..dc8552e3 100644 --- a/backend/common/context.py +++ b/backend/common/context.py @@ -22,6 +22,7 @@ class TypedContextProtocol(Protocol): language: str user_id: int | None + is_superuser: bool class TypedContext(TypedContextProtocol, _Context): diff --git a/backend/common/security/jwt.py b/backend/common/security/jwt.py index eac40547..a3977ecc 100644 --- a/backend/common/security/jwt.py +++ b/backend/common/security/jwt.py @@ -255,7 +255,9 @@ async def jwt_authentication(token: str) -> GetUserInfoWithRelationDetail: if token != redis_token: raise errors.TokenError(msg='Token 已失效') - return await get_jwt_user(ctx.user_id) + user = await get_jwt_user(ctx.user_id) + ctx.is_superuser = user.is_superuser + return user def jwt_authentication_verify(