diff --git a/apps/audits/signal_handlers/login_log.py b/apps/audits/signal_handlers/login_log.py index cdcf244cb..11000830b 100644 --- a/apps/audits/signal_handlers/login_log.py +++ b/apps/audits/signal_handlers/login_log.py @@ -128,7 +128,6 @@ def on_user_auth_success(sender, user, request, login_type=None, **kwargs): request.session['login_time'] = data['datetime'].strftime('%Y-%m-%d %H:%M:%S') data.update({'mfa': int(user.mfa_enabled), 'status': True}) instance = write_login_log(**data) - create_user_session(request, user.id, instance) request.session['user_log_id'] = str(instance.id) request.session['can_send_notifications'] = True diff --git a/apps/authentication/forms.py b/apps/authentication/forms.py index bb14af676..d7a1df484 100644 --- a/apps/authentication/forms.py +++ b/apps/authentication/forms.py @@ -31,7 +31,7 @@ class UserLoginForm(forms.Form): auto_login = forms.BooleanField( required=False, initial=False, widget=forms.CheckboxInput(), - label=_('Auto login next') + label=_('Auto-login') ) def __init__(self, *args, **kwargs): diff --git a/apps/authentication/templates/authentication/login.html b/apps/authentication/templates/authentication/login.html index e7219de27..fac9974ce 100644 --- a/apps/authentication/templates/authentication/login.html +++ b/apps/authentication/templates/authentication/login.html @@ -215,13 +215,7 @@ } .auto-login input[type=checkbox] { - position: relative; - display: inline-block; - margin-top: 0; - vertical-align: middle; - width: 13px; - height: 13px; - cursor: pointer; + } .error-info { diff --git a/apps/authentication/views/login.py b/apps/authentication/views/login.py index 42289460a..904e6cecd 100644 --- a/apps/authentication/views/login.py +++ b/apps/authentication/views/login.py @@ -25,6 +25,7 @@ from django.views.generic.base import TemplateView, RedirectView from django.views.generic.edit import FormView from common.utils import FlashMessageUtil, static_or_direct, safe_next_url +from common.const import Language from users.utils import ( redirect_user_first_login_or_index ) @@ -116,21 +117,10 @@ class UserLoginContextMixin: def get_support_langs(): langs = [ { - 'title': '中文(简体)', - 'code': 'zh-hans' - }, - { - 'title': '中文(繁體)', - 'code': 'zh-hant' - }, - { - 'title': 'English', - 'code': 'en' - }, - { - 'title': '日本語', - 'code': 'ja' + 'title': title, + 'code': code } + for code, title in Language.choices ] return langs @@ -338,7 +328,6 @@ class UserLoginGuardView(mixins.AuthMixin, RedirectView): self.check_user_mfa_if_need(user) self.check_user_login_confirm_if_need(user) except (errors.CredentialError, errors.SessionEmptyError) as e: - print("Error: ", e) return self.format_redirect_url(self.login_url) except errors.MFARequiredError: return self.format_redirect_url(self.login_mfa_url) diff --git a/apps/common/const/choices.py b/apps/common/const/choices.py index 86f0f00db..ef898f54f 100644 --- a/apps/common/const/choices.py +++ b/apps/common/const/choices.py @@ -21,6 +21,14 @@ class Status(models.TextChoices): canceled = 'canceled', _("Canceled") +class Language(models.TextChoices): + auto = 'auto', _('Auto') + en = 'en', 'English' + zh_hans = 'zh-hans', '中文(简体)' + zh_hant = 'zh-hant', '中文(繁體)' + jp = 'ja', '日本語', + + COUNTRY_CALLING_CODES = [ {'name': 'China(中国)', 'value': '+86'}, {'name': 'HongKong(中国香港)', 'value': '+852'}, diff --git a/apps/i18n/core/en/LC_MESSAGES/django.po b/apps/i18n/core/en/LC_MESSAGES/django.po index 390f2c147..4a8ce0a06 100644 --- a/apps/i18n/core/en/LC_MESSAGES/django.po +++ b/apps/i18n/core/en/LC_MESSAGES/django.po @@ -2998,8 +2998,8 @@ msgid "Your password has expired, please reset before logging in" msgstr "" #: authentication/forms.py:34 -msgid "Auto login next" -msgstr "" +msgid "Auto-login" +msgstr "Remember me" #: authentication/forms.py:52 msgid "MFA Code" @@ -8246,11 +8246,11 @@ msgid "" msgstr "" #: users/serializers/preference/luna.py:59 -msgid "Remote application connection method" +msgid "Remote app connect method" msgstr "" #: users/serializers/preference/luna.py:66 -msgid "Character terminal font size" +msgid "Terminal font size" msgstr "" #: users/serializers/preference/luna.py:69 diff --git a/apps/i18n/core/ja/LC_MESSAGES/django.po b/apps/i18n/core/ja/LC_MESSAGES/django.po index d0d179490..1ed297ede 100644 --- a/apps/i18n/core/ja/LC_MESSAGES/django.po +++ b/apps/i18n/core/ja/LC_MESSAGES/django.po @@ -3059,9 +3059,7 @@ msgstr "" "パスワードの有効期限が切れました。ログインする前にリセットしてください。" #: authentication/forms.py:34 -#, fuzzy -#| msgid "Auto login" -msgid "Auto login next" +msgid "Auto-login" msgstr "自動ログイン" #: authentication/forms.py:52 @@ -8485,11 +8483,11 @@ msgstr "" # "ピュータのウィンドウサイズに合わせるためにリモートコンピュータ上のコンテンツ" # "をスケーリングすべきかどうかを判断する" #: users/serializers/preference/luna.py:59 -msgid "Remote application connection method" +msgid "Remote app connect method" msgstr "リモートアプリケーション接続方式" #: users/serializers/preference/luna.py:66 -msgid "Character terminal font size" +msgid "Terminal font size" msgstr "文字終端フォントサイズ" #: users/serializers/preference/luna.py:69 diff --git a/apps/i18n/core/zh/LC_MESSAGES/django.po b/apps/i18n/core/zh/LC_MESSAGES/django.po index 8acd82831..02b644f24 100644 --- a/apps/i18n/core/zh/LC_MESSAGES/django.po +++ b/apps/i18n/core/zh/LC_MESSAGES/django.po @@ -3027,9 +3027,7 @@ msgid "Your password has expired, please reset before logging in" msgstr "您的密码已过期,先修改再登录" #: authentication/forms.py:34 -#, fuzzy -#| msgid "Auto login" -msgid "Auto login next" +msgid "Auto-login" msgstr "自动登录" #: authentication/forms.py:52 @@ -8384,11 +8382,11 @@ msgstr "" "的窗口大小" #: users/serializers/preference/luna.py:59 -msgid "Remote application connection method" +msgid "Remote app connect method" msgstr "远程应用连接方式" #: users/serializers/preference/luna.py:66 -msgid "Character terminal font size" +msgid "Terminal font size" msgstr "字符终端字体大小" #: users/serializers/preference/luna.py:69 diff --git a/apps/users/serializers/preference/lina.py b/apps/users/serializers/preference/lina.py index 5e45715e1..c318fdc2d 100644 --- a/apps/users/serializers/preference/lina.py +++ b/apps/users/serializers/preference/lina.py @@ -1,18 +1,19 @@ from django.utils.translation import gettext_lazy as _ from rest_framework import serializers +from common.const import Language from common.serializers.fields import EncryptedField from ...models import Preference -class BasicSerializer(serializers.Serializer): +class FileEncryptSerializer(serializers.Serializer): has_secret_key = serializers.SerializerMethodField( help_text=_( '*! The password for file encryption, ' 'used for decryption when the system sends emails containing file attachments. ' '
' 'Such as: account backup files, account password change results files' - ) + ), ) secret_key = EncryptedField( required=False, max_length=1024, @@ -42,5 +43,10 @@ class BasicSerializer(serializers.Serializer): return attrs +class BasicSerializer(serializers.Serializer): + lang = serializers.ChoiceField(required=False, choices=Language.choices, label=_('Language'), default=Language.auto) + + class LinaSerializer(serializers.Serializer): - basic = BasicSerializer(required=False, label=_('File Encryption')) + # basic = BasicSerializer(required=False, label=_('Basic')) + file = FileEncryptSerializer(required=False, label=_('File Encryption')) diff --git a/apps/users/serializers/preference/luna.py b/apps/users/serializers/preference/luna.py index 0061bb765..5c9ad6837 100644 --- a/apps/users/serializers/preference/luna.py +++ b/apps/users/serializers/preference/luna.py @@ -5,7 +5,7 @@ from rest_framework import serializers from users.const import ( RDPResolution, RDPSmartSize, KeyboardLayout, ConnectDefaultOpenMethod, - RDPClientOption, AppletConnectionMethod, RDPColorQuality, + RDPClientOption, AppletConnectionMethod, RDPColorQuality, FileNameConflictResolution ) @@ -56,14 +56,18 @@ class GraphicsSerializer(serializers.Serializer): ) applet_connection_method = serializers.ChoiceField( AppletConnectionMethod.choices, default=AppletConnectionMethod.WEB, - required=False, label=_('Remote application connection method') + required=False, label=_('Remote app connect method') + ) + file_name_conflict_resolution = serializers.ChoiceField( + FileNameConflictResolution.choices, default=FileNameConflictResolution.REPLACE, + required=False, label=_('File name conflict resolution') ) class CommandLineSerializer(serializers.Serializer): character_terminal_font_size = serializers.IntegerField( default=14, min_value=1, max_value=9999, required=False, - label=_('Character terminal font size'), + label=_('Terminal font size'), ) is_backspace_as_ctrl_h = serializers.BooleanField( required=False, default=False, label=_('Backspace as Ctrl+H') @@ -71,6 +75,10 @@ class CommandLineSerializer(serializers.Serializer): is_right_click_quickly_paste = serializers.BooleanField( required=False, default=False, label=_('Right click quickly paste') ) + terminal_theme_name = serializers.CharField( + max_length=128, required=False, default='Default', + label=_('Terminal theme name'), + ) class LunaSerializer(serializers.Serializer):