Skip to content

Commit 66c868e

Browse files
authored
fix: anonymous authentication (#3214)
1 parent 3807cf1 commit 66c868e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

apps/common/auth/handle/impl/chat_anonymous_user_token.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
from common.auth.handle.auth_base_handle import AuthBaseHandle
1515
from common.constants.authentication_type import AuthenticationType
1616
from common.constants.permission_constants import RoleConstants, Permission, Group, Operate, ChatAuth
17-
from common.exception.app_exception import AppAuthenticationFailed, ChatException
17+
from common.database_model_manage.database_model_manage import DatabaseModelManage
18+
from common.exception.app_exception import AppAuthenticationFailed
1819

1920

2021
class ChatAnonymousUserToken(AuthBaseHandle):
@@ -40,10 +41,11 @@ def handle(self, request, token: str, get_token_details):
4041
raise AppAuthenticationFailed(1002, _('Authentication information is incorrect'))
4142
if not application_access_token.access_token == access_token:
4243
raise AppAuthenticationFailed(1002, _('Authentication information is incorrect'))
43-
# 匿名用户 除了/api/application/profile 都需要校验是否开启了密码认证
44-
if request.path != '/api/application/profile':
45-
if chat_user_token.authentication.is_auth and not chat_user_token.authentication.auth_passed:
46-
raise ChatException(1002, _('Authentication information is incorrect'))
44+
application_setting_model = DatabaseModelManage.get_model("application_setting")
45+
if application_setting_model is not None:
46+
application_setting = QuerySet(application_setting_model).filter(application_id=application_id).first()
47+
if application_setting.authentication:
48+
raise AppAuthenticationFailed(1002, _('Authentication information is incorrect'))
4749
return None, ChatAuth(
4850
current_role_list=[RoleConstants.CHAT_ANONYMOUS_USER],
4951
permission_list=[

0 commit comments

Comments
 (0)