1414from common .auth .handle .auth_base_handle import AuthBaseHandle
1515from common .constants .authentication_type import AuthenticationType
1616from 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
2021class 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