Skip to content

Commit 27bb328

Browse files
committed
fix: 修复用户未登录错误
1 parent c361789 commit 27bb328

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

fastapi_user_auth/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.6.0"
1+
__version__ = "0.6.0a6"
22
__url__ = "https://github.com/amisadmin/fastapi_user_auth"
33

44
import gettext

fastapi_user_auth/admin/app.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from fastapi_user_auth.admin import UserRegFormAdmin as DefaultUserRegFormAdmin
1616
from fastapi_user_auth.admin.utils import get_admin_action_options_by_subject
1717
from fastapi_user_auth.auth import AuthRouter
18+
from fastapi_user_auth.auth.schemas import SystemUserEnum
1819

1920

2021
class UserAuthApp(AdminApp, AuthRouter):
@@ -65,11 +66,9 @@ def register_router(self):
6566
@self.router.get("/site_admin_actions_options", response_model=BaseApiOut)
6667
async def site_admin_actions_options(request: Request):
6768
# 获取当前登录用户的权限
68-
user = await self.auth.get_current_user(request)
69+
username = await self.auth.get_current_user_identity(request) or SystemUserEnum.GUEST
6970
# 获取当前用户的权限列表
70-
options = get_admin_action_options_by_subject(
71-
enforcer=self.auth.enforcer, subject="u:" + user.username, group=self.site
72-
)
71+
options = get_admin_action_options_by_subject(enforcer=self.auth.enforcer, subject="u:" + username, group=self.site)
7372
return BaseApiOut(data=options)
7473

7574
return self

0 commit comments

Comments
 (0)