|
9 | 9 |
|
10 | 10 | import json |
11 | 11 | import uuid_utils.compat as uuid |
12 | | -from django.core import signing |
13 | 12 | from django.core.cache import cache |
14 | 13 | from django.utils.translation import gettext_lazy as _ |
15 | 14 | from rest_framework import serializers |
16 | 15 |
|
| 16 | +from common.auth.common import ChatToken |
| 17 | +from common.auth.constants.operate_constants import Operate |
| 18 | +from common.constants.authentication_type import AuthenticationType |
17 | 19 | from common.constants.cache_version import Cache_Version |
18 | 20 | from common.database_model_manage.database_model_manage import DatabaseModelManage |
19 | 21 | from common.exception.app_exception import AppApiException |
@@ -183,14 +185,8 @@ def login(instance): |
183 | 185 | cache.delete(cache_key, version=system_version) |
184 | 186 | cache.delete(system_get_key(f"portal_{username}_lock"), version=system_version) |
185 | 187 |
|
186 | | - token = signing.dumps( |
187 | | - { |
188 | | - "username": user.username, |
189 | | - "id": str(user.id), |
190 | | - "type": "PORTAL_USER", |
191 | | - } |
192 | | - ) |
193 | | - version, get_key = Cache_Version.TOKEN.value |
| 188 | + token = ChatToken(str(user.id), AuthenticationType.CHAT_USER, str(Operate.LOCAL)).to_token() |
| 189 | + version, get_key = Cache_Version.CHAT_USER_TOKEN.value |
194 | 190 | timeout = CONFIG.get_session_timeout() |
195 | 191 | cache.set(get_key(token), user, timeout=timeout, version=version) |
196 | 192 | record_log( |
|
0 commit comments