feat: enhance chat authentication logic and update model handling for chat platform
This commit is contained in:
parent
9f31832b4d
commit
dd7b2a7bda
@ -64,8 +64,14 @@ class AuthProfileSerializer(serializers.Serializer):
|
|||||||
'authentication': False
|
'authentication': False
|
||||||
}
|
}
|
||||||
application_setting_model = DatabaseModelManage.get_model('application_setting')
|
application_setting_model = DatabaseModelManage.get_model('application_setting')
|
||||||
if application_setting_model:
|
chat_platform = DatabaseModelManage.get_model('chat_platform')
|
||||||
|
if application_setting_model and chat_platform:
|
||||||
application_setting = QuerySet(application_setting_model).filter(application_id=application_id).first()
|
application_setting = QuerySet(application_setting_model).filter(application_id=application_id).first()
|
||||||
|
types = QuerySet(chat_platform).filter(is_active=True, is_valid=True).values_list('auth_type', flat=True)
|
||||||
|
login_value = application_access_token.authentication_value.get('login_value', [])
|
||||||
|
final_login_value = list(set(login_value) & set(types))
|
||||||
|
if 'LOCAL' in login_value:
|
||||||
|
final_login_value.insert(0, 'LOCAL')
|
||||||
if application_setting is not None:
|
if application_setting is not None:
|
||||||
profile = {
|
profile = {
|
||||||
'icon': application_setting.application.icon,
|
'icon': application_setting.application.icon,
|
||||||
@ -74,7 +80,7 @@ class AuthProfileSerializer(serializers.Serializer):
|
|||||||
'authentication': application_access_token.authentication,
|
'authentication': application_access_token.authentication,
|
||||||
'authentication_type': application_access_token.authentication_value.get(
|
'authentication_type': application_access_token.authentication_value.get(
|
||||||
'type', 'password'),
|
'type', 'password'),
|
||||||
'login_value': application_access_token.authentication_value.get('login_value', [])
|
'login_value': final_login_value
|
||||||
}
|
}
|
||||||
return profile
|
return profile
|
||||||
|
|
||||||
|
|||||||
@ -211,7 +211,6 @@ class UserManageSerializer(serializers.Serializer):
|
|||||||
is_active = serializers.BooleanField(
|
is_active = serializers.BooleanField(
|
||||||
required=False,
|
required=False,
|
||||||
label=_("Is active"),
|
label=_("Is active"),
|
||||||
default=True
|
|
||||||
)
|
)
|
||||||
source = serializers.CharField(
|
source = serializers.CharField(
|
||||||
required=False,
|
required=False,
|
||||||
@ -223,7 +222,7 @@ class UserManageSerializer(serializers.Serializer):
|
|||||||
username = self.data.get('username')
|
username = self.data.get('username')
|
||||||
nick_name = self.data.get('nick_name')
|
nick_name = self.data.get('nick_name')
|
||||||
email = self.data.get('email')
|
email = self.data.get('email')
|
||||||
is_active = self.data.get('is_active', True)
|
is_active = self.data.get('is_active', None)
|
||||||
source = self.data.get('source', None)
|
source = self.data.get('source', None)
|
||||||
query_set = QuerySet(User)
|
query_set = QuerySet(User)
|
||||||
if username is not None:
|
if username is not None:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user