diff --git a/apps/chat/serializers/chat_authentication.py b/apps/chat/serializers/chat_authentication.py index bbcd57846..953fdb595 100644 --- a/apps/chat/serializers/chat_authentication.py +++ b/apps/chat/serializers/chat_authentication.py @@ -45,7 +45,7 @@ class AnonymousAuthenticationSerializer(serializers.Serializer): _type = AuthenticationType.CHAT_ANONYMOUS_USER return ChatUserToken(application_access_token.application_id, None, access_token, _type, ChatUserType.ANONYMOUS_USER, - chat_user_id, ChatAuthentication(None, False, False)).to_token() + chat_user_id, ChatAuthentication(None)).to_token() else: raise NotFound404(404, _("Invalid access_token")) diff --git a/apps/common/auth/common.py b/apps/common/auth/common.py index 3b37f28e2..b83539574 100644 --- a/apps/common/auth/common.py +++ b/apps/common/auth/common.py @@ -14,13 +14,11 @@ from common.utils.rsa_util import encrypt, decrypt class ChatAuthentication: - def __init__(self, auth_type: str | None, is_auth: bool, auth_passed: bool): - self.is_auth = is_auth - self.auth_passed = auth_passed + def __init__(self, auth_type: str | None): self.auth_type = auth_type def to_dict(self): - return {'is_auth': self.is_auth, 'auth_passed': self.auth_passed, 'auth_type': self.auth_type} + return {'auth_type': self.auth_type} def to_string(self): return encrypt(json.dumps(self.to_dict())) @@ -28,7 +26,7 @@ class ChatAuthentication: @staticmethod def new_instance(authentication: str): auth = json.loads(decrypt(authentication)) - return ChatAuthentication(auth.get('auth_type'), auth.get('is_auth'), auth.get('auth_passed')) + return ChatAuthentication(auth.get('auth_type')) class ChatUserToken: diff --git a/apps/common/auth/handle/impl/chat_anonymous_user_token.py b/apps/common/auth/handle/impl/chat_anonymous_user_token.py index b815d4784..2296495a0 100644 --- a/apps/common/auth/handle/impl/chat_anonymous_user_token.py +++ b/apps/common/auth/handle/impl/chat_anonymous_user_token.py @@ -45,7 +45,8 @@ class ChatAnonymousUserToken(AuthBaseHandle): if application_setting_model is not None: application_setting = QuerySet(application_setting_model).filter(application_id=application_id).first() if application_setting.authentication: - raise AppAuthenticationFailed(1002, _('Authentication information is incorrect')) + if 'password' != chat_user_token.authentication.auth_type: + raise AppAuthenticationFailed(1002, _('Authentication information is incorrect')) return None, ChatAuth( current_role_list=[RoleConstants.CHAT_ANONYMOUS_USER], permission_list=[