Skip to content

Commit 6c27fe6

Browse files
committed
refactor: simplify cache timeout handling in authentication modules
1 parent dc04d46 commit 6c27fe6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

apps/users/serializers/login.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from common.constants.cache_version import Cache_Version
2121
from common.exception.app_exception import AppApiException
2222
from common.utils.common import password_encrypt, get_random_chars
23+
from maxkb.const import CONFIG
2324
from users.models import User
2425

2526

@@ -58,7 +59,8 @@ def login(instance):
5859
'email': user.email,
5960
'type': AuthenticationType.SYSTEM_USER.value})
6061
version, get_key = Cache_Version.TOKEN.value
61-
cache.set(get_key(token), user, timeout=datetime.timedelta(seconds=60 * 60 * 2).seconds, version=version)
62+
timeout = CONFIG.get_session_timeout()
63+
cache.set(get_key(token), user, timeout=timeout, version=version)
6264
return {'token': token}
6365

6466

0 commit comments

Comments
 (0)