Skip to content

Commit 1dc6d6e

Browse files
committed
feat: add session timeout configuration to Config class
1 parent d4d7bdd commit 1dc6d6e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

apps/common/auth/handle/impl/user_token.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from django.db.models import QuerySet
1515
from django.utils.translation import gettext_lazy as _
1616

17+
from maxkb.const import CONFIG
1718
from common.auth.handle.auth_base_handle import AuthBaseHandle
1819
from common.constants.authentication_type import AuthenticationType
1920
from common.constants.cache_version import Cache_Version
@@ -283,7 +284,9 @@ def handle(self, request, token: str, get_token_details):
283284
if cache_token is None:
284285
raise AppAuthenticationFailed(1002, _('Login expired'))
285286
auth_details = get_token_details()
286-
cache.touch(token, timeout=datetime.timedelta(seconds=60 * 60 * 2).seconds, version=version)
287+
timeout = CONFIG.get_session_timeout()
288+
print(timeout)
289+
cache.touch(token, timeout=datetime.timedelta(seconds=timeout).seconds, version=version)
287290
user = QuerySet(User).get(id=auth_details['id'])
288291
auth = get_auth(user)
289292
return user, auth

apps/maxkb/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ def get_language_code(self):
8484
def get_log_level(self):
8585
return self.get('LOG_LEVEL', 'DEBUG')
8686

87+
def get_session_timeout(self):
88+
return int(self.get('SESSION_TIMEOUT', 25200))
89+
8790
def __init__(self, *args):
8891
super().__init__(*args)
8992

0 commit comments

Comments
 (0)