diff --git a/spug_api/apps/account/views.py b/spug_api/apps/account/views.py index 085ed73..8f60643 100644 --- a/spug_api/apps/account/views.py +++ b/spug_api/apps/account/views.py @@ -2,6 +2,7 @@ # Copyright: (c) # Released under the AGPL-3.0 License. from django.core.cache import cache +from django.conf import settings from libs.mixins import AdminView, View from libs import JsonParser, Argument, human_datetime, json_response from libs.utils import get_request_real_ip, generate_random_str @@ -245,7 +246,7 @@ def handle_user_info(request, user, captcha): x_real_ip = get_request_real_ip(request.headers) token_isvalid = user.access_token and len(user.access_token) == 32 and user.token_expired >= time.time() user.access_token = user.access_token if token_isvalid else uuid.uuid4().hex - user.token_expired = time.time() + 8 * 60 * 60 + user.token_expired = time.time() + settings.TOKEN_TTL user.last_login = human_datetime() user.last_ip = x_real_ip user.save() diff --git a/spug_api/libs/ssh.py b/spug_api/libs/ssh.py index f964c99..7624d72 100644 --- a/spug_api/libs/ssh.py +++ b/spug_api/libs/ssh.py @@ -155,11 +155,10 @@ class SSH: command = 'set +o history\nset +o zle\nset -o no_nomatch\nexport PS1= && stty -echo\n' command = self._handle_command(command, self.default_env) self.channel.sendall(command) - out = line = '' + out = '' while True: if self.channel.recv_ready(): - line = self._decode(self.channel.recv(8196)) - out += line + out += self._decode(self.channel.recv(8196)) if self.regex.search(out): self.stdout = self.channel.makefile('r') break diff --git a/spug_api/spug/settings.py b/spug_api/spug/settings.py index d1938f2..1cbfeea 100644 --- a/spug_api/spug/settings.py +++ b/spug_api/spug/settings.py @@ -102,6 +102,7 @@ TEMPLATES = [ }, ] +TOKEN_TTL = 8 * 3600 SCHEDULE_KEY = 'spug:schedule' SCHEDULE_WORKER_KEY = 'spug:schedule:worker' MONITOR_KEY = 'spug:monitor'