Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
3d9c0a21
Commit
3d9c0a21
authored
Jul 30, 2019
by
BaiJiangJie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 用户登录失败次数提示
parent
32dacecd
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
129 additions
and
78 deletions
+129
-78
forms.py
apps/authentication/forms.py
+31
-2
login.html
apps/authentication/templates/authentication/login.html
+6
-4
new_login.html
apps/authentication/templates/authentication/new_login.html
+3
-1
login.py
apps/authentication/views/login.py
+1
-0
django.mo
apps/locale/zh/LC_MESSAGES/django.mo
+0
-0
django.po
apps/locale/zh/LC_MESSAGES/django.po
+81
-69
utils.py
apps/users/utils.py
+7
-2
No files found.
apps/authentication/forms.py
View file @
3d9c0a21
...
@@ -5,6 +5,8 @@ from django import forms
...
@@ -5,6 +5,8 @@ from django import forms
from
django.contrib.auth.forms
import
AuthenticationForm
from
django.contrib.auth.forms
import
AuthenticationForm
from
django.utils.translation
import
gettext_lazy
as
_
from
django.utils.translation
import
gettext_lazy
as
_
from
captcha.fields
import
CaptchaField
from
captcha.fields
import
CaptchaField
from
django.conf
import
settings
from
users.utils
import
get_login_failed_count
class
UserLoginForm
(
AuthenticationForm
):
class
UserLoginForm
(
AuthenticationForm
):
...
@@ -16,10 +18,18 @@ class UserLoginForm(AuthenticationForm):
...
@@ -16,10 +18,18 @@ class UserLoginForm(AuthenticationForm):
error_messages
=
{
error_messages
=
{
'invalid_login'
:
_
(
'invalid_login'
:
_
(
"
Please enter a correct username and password. Note that both
"
"
The username or password you entered is incorrect,
"
"
fields may be case-sensitive
."
"
please enter it again
."
),
),
'inactive'
:
_
(
"This account is inactive."
),
'inactive'
:
_
(
"This account is inactive."
),
'limit_login'
:
_
(
"You can also try {times_try} times "
"(The account will be temporarily locked for {block_time} minutes)"
),
'block_login'
:
_
(
"The account has been locked "
"(please contact admin to unlock it or try again after {} minutes)"
)
}
}
def
confirm_login_allowed
(
self
,
user
):
def
confirm_login_allowed
(
self
,
user
):
...
@@ -28,6 +38,25 @@ class UserLoginForm(AuthenticationForm):
...
@@ -28,6 +38,25 @@ class UserLoginForm(AuthenticationForm):
self
.
error_messages
[
'inactive'
],
self
.
error_messages
[
'inactive'
],
code
=
'inactive'
,)
code
=
'inactive'
,)
def
get_limit_login_error_message
(
self
,
username
,
ip
):
times_up
=
settings
.
SECURITY_LOGIN_LIMIT_COUNT
times_failed
=
get_login_failed_count
(
username
,
ip
)
times_try
=
int
(
times_up
)
-
int
(
times_failed
)
block_time
=
settings
.
SECURITY_LOGIN_LIMIT_TIME
if
times_try
<=
0
:
error_message
=
self
.
error_messages
[
'block_login'
]
error_message
=
error_message
.
format
(
block_time
)
else
:
error_message
=
self
.
error_messages
[
'limit_login'
]
error_message
=
error_message
.
format
(
times_try
=
times_try
,
block_time
=
block_time
,
)
return
error_message
def
add_limit_login_error
(
self
,
username
,
ip
):
error
=
self
.
get_limit_login_error_message
(
username
,
ip
)
self
.
add_error
(
'password'
,
error
)
class
UserLoginCaptchaForm
(
UserLoginForm
):
class
UserLoginCaptchaForm
(
UserLoginForm
):
captcha
=
CaptchaField
()
captcha
=
CaptchaField
()
...
...
apps/authentication/templates/authentication/login.html
View file @
3d9c0a21
...
@@ -58,6 +58,7 @@
...
@@ -58,6 +58,7 @@
{% else %}
{% else %}
<p
class=
"red-fonts"
>
{{ form.non_field_errors.as_text }}
</p>
<p
class=
"red-fonts"
>
{{ form.non_field_errors.as_text }}
</p>
{% endif %}
{% endif %}
<p
class=
"red-fonts"
>
{{ form.errors.password.as_text }}
</p>
{% endif %}
{% endif %}
<div
class=
"form-group"
>
<div
class=
"form-group"
>
...
@@ -78,10 +79,11 @@
...
@@ -78,10 +79,11 @@
{% endif %}
{% endif %}
<div
class=
"text-muted text-center"
>
<div
class=
"text-muted text-center"
>
<div>
<div>
<a
href=
"{% url 'users:forgot-password' %}"
>
<a
href=
"{% url 'users:forgot-password' %}"
>
<small>
{% trans 'Forgot password' %}?
</small>
<small>
{% trans 'Forgot password' %}?
</small>
</a>
</a>
</div>
</div>
</div>
{% if AUTH_OPENID %}
{% if AUTH_OPENID %}
...
...
apps/authentication/templates/authentication/new_login.html
View file @
3d9c0a21
...
@@ -72,9 +72,10 @@
...
@@ -72,9 +72,10 @@
<div
class=
"contact-form col-md-10"
style=
"margin-top: 10px;height: 35px"
>
<div
class=
"contact-form col-md-10"
style=
"margin-top: 10px;height: 35px"
>
<form
id=
"contact-form"
action=
""
method=
"post"
role=
"form"
novalidate=
"novalidate"
>
<form
id=
"contact-form"
action=
""
method=
"post"
role=
"form"
novalidate=
"novalidate"
>
{% csrf_token %}
{% csrf_token %}
<div
style=
"height:
45
px;color: red;line-height: 17px;"
>
<div
style=
"height:
70
px;color: red;line-height: 17px;"
>
{% if block_login %}
{% if block_login %}
<p
class=
"red-fonts"
>
{% trans 'Log in frequently and try again later' %}
</p>
<p
class=
"red-fonts"
>
{% trans 'Log in frequently and try again later' %}
</p>
<p
class=
"red-fonts"
>
{{ form.errors.password.as_text }}
</p>
{% elif password_expired %}
{% elif password_expired %}
<p
class=
"red-fonts"
>
{% trans 'The user password has expired' %}
</p>
<p
class=
"red-fonts"
>
{% trans 'The user password has expired' %}
</p>
{% elif form.errors %}
{% elif form.errors %}
...
@@ -83,6 +84,7 @@
...
@@ -83,6 +84,7 @@
{% else %}
{% else %}
<p
class=
"red-fonts"
>
{{ form.non_field_errors.as_text }}
</p>
<p
class=
"red-fonts"
>
{{ form.non_field_errors.as_text }}
</p>
{% endif %}
{% endif %}
<p
class=
"red-fonts"
>
{{ form.errors.password.as_text }}
</p>
{% endif %}
{% endif %}
</div>
</div>
...
...
apps/authentication/views/login.py
View file @
3d9c0a21
...
@@ -100,6 +100,7 @@ class UserLoginView(FormView):
...
@@ -100,6 +100,7 @@ class UserLoginView(FormView):
# limit user login failed count
# limit user login failed count
ip
=
get_request_ip
(
self
.
request
)
ip
=
get_request_ip
(
self
.
request
)
increase_login_failed_count
(
username
,
ip
)
increase_login_failed_count
(
username
,
ip
)
form
.
add_limit_login_error
(
username
,
ip
)
# show captcha
# show captcha
cache
.
set
(
self
.
key_prefix_captcha
.
format
(
ip
),
1
,
3600
)
cache
.
set
(
self
.
key_prefix_captcha
.
format
(
ip
),
1
,
3600
)
self
.
send_auth_signal
(
success
=
False
,
username
=
username
,
reason
=
reason
)
self
.
send_auth_signal
(
success
=
False
,
username
=
username
,
reason
=
reason
)
...
...
apps/locale/zh/LC_MESSAGES/django.mo
View file @
3d9c0a21
No preview for this file type
apps/locale/zh/LC_MESSAGES/django.po
View file @
3d9c0a21
...
@@ -8,7 +8,7 @@ msgid ""
...
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
msgstr ""
"Project-Id-Version: Jumpserver 0.3.3\n"
"Project-Id-Version: Jumpserver 0.3.3\n"
"Report-Msgid-Bugs-To: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-07-
29 18:24
+0800\n"
"POT-Creation-Date: 2019-07-
30 18:48
+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: ibuler <ibuler@qq.com>\n"
"Last-Translator: ibuler <ibuler@qq.com>\n"
"Language-Team: Jumpserver team<ibuler@qq.com>\n"
"Language-Team: Jumpserver team<ibuler@qq.com>\n"
...
@@ -429,29 +429,29 @@ msgstr "详情"
...
@@ -429,29 +429,29 @@ msgstr "详情"
#: assets/templates/assets/system_user_list.html:33
#: assets/templates/assets/system_user_list.html:33
#: assets/templates/assets/system_user_list.html:85 audits/models.py:33
#: assets/templates/assets/system_user_list.html:85 audits/models.py:33
#: perms/templates/perms/asset_permission_detail.html:30
#: perms/templates/perms/asset_permission_detail.html:30
#: perms/templates/perms/asset_permission_list.html:17
7
#: perms/templates/perms/asset_permission_list.html:17
8
#: perms/templates/perms/remote_app_permission_detail.html:30
#: perms/templates/perms/remote_app_permission_detail.html:30
#: perms/templates/perms/remote_app_permission_list.html:59
#: perms/templates/perms/remote_app_permission_list.html:59
#: terminal/templates/terminal/terminal_detail.html:16
#: terminal/templates/terminal/terminal_detail.html:16
#: terminal/templates/terminal/terminal_list.html:7
2
#: terminal/templates/terminal/terminal_list.html:7
3
#: users/templates/users/user_detail.html:25
#: users/templates/users/user_detail.html:25
#: users/templates/users/user_group_detail.html:28
#: users/templates/users/user_group_detail.html:28
#: users/templates/users/user_group_list.html:20
#: users/templates/users/user_group_list.html:20
#: users/templates/users/user_group_list.html:7
0
#: users/templates/users/user_group_list.html:7
1
#: users/templates/users/user_list.html:20
#: users/templates/users/user_list.html:20
#: users/templates/users/user_list.html:10
2
#: users/templates/users/user_list.html:10
3
#: users/templates/users/user_list.html:10
5
#: users/templates/users/user_list.html:10
6
#: users/templates/users/user_profile.html:181
#: users/templates/users/user_profile.html:181
#: users/templates/users/user_profile.html:191
#: users/templates/users/user_profile.html:191
#: users/templates/users/user_profile.html:201
#: users/templates/users/user_profile.html:201
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:29
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:29
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:5
5
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:5
6
#: xpack/plugins/cloud/templates/cloud/account_detail.html:23
#: xpack/plugins/cloud/templates/cloud/account_detail.html:23
#: xpack/plugins/cloud/templates/cloud/account_list.html:
39
#: xpack/plugins/cloud/templates/cloud/account_list.html:
40
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:29
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:29
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:5
6
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:5
7
#: xpack/plugins/orgs/templates/orgs/org_detail.html:25
#: xpack/plugins/orgs/templates/orgs/org_detail.html:25
#: xpack/plugins/orgs/templates/orgs/org_list.html:8
7
#: xpack/plugins/orgs/templates/orgs/org_list.html:8
8
msgid "Update"
msgid "Update"
msgstr "更新"
msgstr "更新"
...
@@ -473,25 +473,25 @@ msgstr "更新"
...
@@ -473,25 +473,25 @@ msgstr "更新"
#: assets/templates/assets/system_user_list.html:86 audits/models.py:34
#: assets/templates/assets/system_user_list.html:86 audits/models.py:34
#: ops/templates/ops/task_list.html:64
#: ops/templates/ops/task_list.html:64
#: perms/templates/perms/asset_permission_detail.html:34
#: perms/templates/perms/asset_permission_detail.html:34
#: perms/templates/perms/asset_permission_list.html:17
8
#: perms/templates/perms/asset_permission_list.html:17
9
#: perms/templates/perms/remote_app_permission_detail.html:34
#: perms/templates/perms/remote_app_permission_detail.html:34
#: perms/templates/perms/remote_app_permission_list.html:60
#: perms/templates/perms/remote_app_permission_list.html:60
#: settings/templates/settings/terminal_setting.html:93
#: settings/templates/settings/terminal_setting.html:93
#: settings/templates/settings/terminal_setting.html:115
#: settings/templates/settings/terminal_setting.html:115
#: terminal/templates/terminal/terminal_list.html:7
4
#: terminal/templates/terminal/terminal_list.html:7
5
#: users/templates/users/user_detail.html:30
#: users/templates/users/user_detail.html:30
#: users/templates/users/user_group_detail.html:32
#: users/templates/users/user_group_detail.html:32
#: users/templates/users/user_group_list.html:7
2
#: users/templates/users/user_group_list.html:7
3
#: users/templates/users/user_list.html:11
0
#: users/templates/users/user_list.html:11
1
#: users/templates/users/user_list.html:11
4
#: users/templates/users/user_list.html:11
5
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:33
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:33
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:5
7
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:5
8
#: xpack/plugins/cloud/templates/cloud/account_detail.html:27
#: xpack/plugins/cloud/templates/cloud/account_detail.html:27
#: xpack/plugins/cloud/templates/cloud/account_list.html:4
1
#: xpack/plugins/cloud/templates/cloud/account_list.html:4
2
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:33
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:33
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:5
7
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:5
8
#: xpack/plugins/orgs/templates/orgs/org_detail.html:29
#: xpack/plugins/orgs/templates/orgs/org_detail.html:29
#: xpack/plugins/orgs/templates/orgs/org_list.html:
89
#: xpack/plugins/orgs/templates/orgs/org_list.html:
90
msgid "Delete"
msgid "Delete"
msgstr "删除"
msgstr "删除"
...
@@ -719,9 +719,9 @@ msgstr "SSH网关,支持代理SSH,RDP和VNC"
...
@@ -719,9 +719,9 @@ msgstr "SSH网关,支持代理SSH,RDP和VNC"
#: assets/templates/assets/domain_gateway_list.html:71
#: assets/templates/assets/domain_gateway_list.html:71
#: assets/templates/assets/system_user_detail.html:62
#: assets/templates/assets/system_user_detail.html:62
#: assets/templates/assets/system_user_list.html:52 audits/models.py:94
#: assets/templates/assets/system_user_list.html:52 audits/models.py:94
#: audits/templates/audits/login_log_list.html:51 authentication/forms.py:1
1
#: audits/templates/audits/login_log_list.html:51 authentication/forms.py:1
3
#: authentication/templates/authentication/login.html:6
4
#: authentication/templates/authentication/login.html:6
5
#: authentication/templates/authentication/new_login.html:9
0
#: authentication/templates/authentication/new_login.html:9
1
#: ops/models/adhoc.py:164 perms/templates/perms/asset_permission_list.html:70
#: ops/models/adhoc.py:164 perms/templates/perms/asset_permission_list.html:70
#: perms/templates/perms/asset_permission_user.html:55
#: perms/templates/perms/asset_permission_user.html:55
#: perms/templates/perms/remote_app_permission_user.html:54
#: perms/templates/perms/remote_app_permission_user.html:54
...
@@ -748,9 +748,9 @@ msgstr "密码或密钥密码"
...
@@ -748,9 +748,9 @@ msgstr "密码或密钥密码"
#: assets/serializers/asset_user.py:62
#: assets/serializers/asset_user.py:62
#: assets/templates/assets/_asset_user_auth_update_modal.html:21
#: assets/templates/assets/_asset_user_auth_update_modal.html:21
#: assets/templates/assets/_asset_user_auth_view_modal.html:27
#: assets/templates/assets/_asset_user_auth_view_modal.html:27
#: authentication/forms.py:1
3
#: authentication/forms.py:1
5
#: authentication/templates/authentication/login.html:6
7
#: authentication/templates/authentication/login.html:6
8
#: authentication/templates/authentication/new_login.html:9
3
#: authentication/templates/authentication/new_login.html:9
4
#: settings/forms.py:110 users/forms.py:16 users/forms.py:28
#: settings/forms.py:110 users/forms.py:16 users/forms.py:28
#: users/templates/users/reset_password.html:53
#: users/templates/users/reset_password.html:53
#: users/templates/users/user_password_authentication.html:18
#: users/templates/users/user_password_authentication.html:18
...
@@ -1595,8 +1595,8 @@ msgstr "选择节点"
...
@@ -1595,8 +1595,8 @@ msgstr "选择节点"
#: users/templates/users/user_detail.html:441
#: users/templates/users/user_detail.html:441
#: users/templates/users/user_detail.html:486
#: users/templates/users/user_detail.html:486
#: users/templates/users/user_group_create_update.html:32
#: users/templates/users/user_group_create_update.html:32
#: users/templates/users/user_group_list.html:1
19
#: users/templates/users/user_group_list.html:1
20
#: users/templates/users/user_list.html:25
5
#: users/templates/users/user_list.html:25
6
#: xpack/plugins/cloud/templates/cloud/account_create_update.html:34
#: xpack/plugins/cloud/templates/cloud/account_create_update.html:34
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_create_update.html:54
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_create_update.html:54
#: xpack/plugins/interface/templates/interface/interface.html:103
#: xpack/plugins/interface/templates/interface/interface.html:103
...
@@ -1649,10 +1649,10 @@ msgstr "创建管理用户"
...
@@ -1649,10 +1649,10 @@ msgstr "创建管理用户"
#: assets/templates/assets/asset_list.html:304
#: assets/templates/assets/asset_list.html:304
#: assets/templates/assets/system_user_list.html:192
#: assets/templates/assets/system_user_list.html:192
#: assets/templates/assets/system_user_list.html:223
#: assets/templates/assets/system_user_list.html:223
#: users/templates/users/user_group_list.html:16
3
#: users/templates/users/user_group_list.html:16
4
#: users/templates/users/user_group_list.html:19
4
#: users/templates/users/user_group_list.html:19
5
#: users/templates/users/user_list.html:16
4
#: users/templates/users/user_list.html:16
5
#: users/templates/users/user_list.html:19
6
#: users/templates/users/user_list.html:19
7
#: xpack/plugins/vault/templates/vault/vault.html:224
#: xpack/plugins/vault/templates/vault/vault.html:224
msgid "Please select file"
msgid "Please select file"
msgstr "选择文件"
msgstr "选择文件"
...
@@ -1792,8 +1792,8 @@ msgstr "显示所有子节点资产"
...
@@ -1792,8 +1792,8 @@ msgstr "显示所有子节点资产"
#: users/templates/users/user_detail.html:386
#: users/templates/users/user_detail.html:386
#: users/templates/users/user_detail.html:412
#: users/templates/users/user_detail.html:412
#: users/templates/users/user_detail.html:480
#: users/templates/users/user_detail.html:480
#: users/templates/users/user_group_list.html:11
3
#: users/templates/users/user_group_list.html:11
4
#: users/templates/users/user_list.html:2
49
#: users/templates/users/user_list.html:2
50
#: xpack/plugins/interface/templates/interface/interface.html:97
#: xpack/plugins/interface/templates/interface/interface.html:97
msgid "Are you sure?"
msgid "Are you sure?"
msgstr "你确认吗?"
msgstr "你确认吗?"
...
@@ -1809,8 +1809,8 @@ msgstr "删除选择资产"
...
@@ -1809,8 +1809,8 @@ msgstr "删除选择资产"
#: users/templates/users/user_detail.html:416
#: users/templates/users/user_detail.html:416
#: users/templates/users/user_detail.html:484
#: users/templates/users/user_detail.html:484
#: users/templates/users/user_group_create_update.html:31
#: users/templates/users/user_group_create_update.html:31
#: users/templates/users/user_group_list.html:11
7
#: users/templates/users/user_group_list.html:11
8
#: users/templates/users/user_list.html:25
3
#: users/templates/users/user_list.html:25
4
#: xpack/plugins/interface/templates/interface/interface.html:101
#: xpack/plugins/interface/templates/interface/interface.html:101
#: xpack/plugins/orgs/templates/orgs/org_create_update.html:32
#: xpack/plugins/orgs/templates/orgs/org_create_update.html:32
msgid "Cancel"
msgid "Cancel"
...
@@ -2392,17 +2392,29 @@ msgstr ""
...
@@ -2392,17 +2392,29 @@ msgstr ""
msgid "Invalid token or cache refreshed."
msgid "Invalid token or cache refreshed."
msgstr ""
msgstr ""
#: authentication/forms.py:
19
#: authentication/forms.py:
21
msgid ""
msgid ""
"Please enter a correct username and password. Note that both fields may be "
"The username or password you entered is incorrect, please enter it again."
"case-sensitive."
msgstr "您输入的用户名或密码不正确,请重新输入。"
msgstr "请输入正确的用户名和密码. 注意它们是区分大小写."
#: authentication/forms.py:2
2
#: authentication/forms.py:2
4
msgid "This account is inactive."
msgid "This account is inactive."
msgstr "此账户无效"
msgstr "此账户无效"
#: authentication/forms.py:37 users/forms.py:22
#: authentication/forms.py:26
#, python-brace-format
msgid ""
"You can also try {times_try} times (The account will be temporarily locked "
"for {block_time} minutes)"
msgstr "您还可以尝试 {times_try} 次(账号将被临时锁定 {block_time} 分钟)"
#: authentication/forms.py:30
msgid ""
"The account has been locked (please contact admin to unlock it or try again "
"after {} minutes)"
msgstr "账号已被锁定(请联系管理员解锁 或 {}分钟后重试)"
#: authentication/forms.py:66 users/forms.py:22
msgid "MFA code"
msgid "MFA code"
msgstr "MFA 验证码"
msgstr "MFA 验证码"
...
@@ -2466,8 +2478,8 @@ msgid "Changes the world, starting with a little bit."
...
@@ -2466,8 +2478,8 @@ msgid "Changes the world, starting with a little bit."
msgstr "改变世界,从一点点开始。"
msgstr "改变世界,从一点点开始。"
#: authentication/templates/authentication/login.html:46
#: authentication/templates/authentication/login.html:46
#: authentication/templates/authentication/login.html:7
2
#: authentication/templates/authentication/login.html:7
3
#: authentication/templates/authentication/new_login.html:
99
#: authentication/templates/authentication/new_login.html:
100
#: templates/_header_bar.html:101
#: templates/_header_bar.html:101
msgid "Login"
msgid "Login"
msgstr "登录"
msgstr "登录"
...
@@ -2482,18 +2494,18 @@ msgstr "用户密码已过期"
...
@@ -2482,18 +2494,18 @@ msgstr "用户密码已过期"
msgid "Captcha invalid"
msgid "Captcha invalid"
msgstr "验证码错误"
msgstr "验证码错误"
#: authentication/templates/authentication/login.html:8
3
#: authentication/templates/authentication/login.html:8
4
#: authentication/templates/authentication/new_login.html:10
3
#: authentication/templates/authentication/new_login.html:10
4
#: users/templates/users/forgot_password.html:10
#: users/templates/users/forgot_password.html:10
#: users/templates/users/forgot_password.html:25
#: users/templates/users/forgot_password.html:25
msgid "Forgot password"
msgid "Forgot password"
msgstr "忘记密码"
msgstr "忘记密码"
#: authentication/templates/authentication/login.html:
89
#: authentication/templates/authentication/login.html:
91
msgid "More login options"
msgid "More login options"
msgstr "更多登录方式"
msgstr "更多登录方式"
#: authentication/templates/authentication/login.html:9
3
#: authentication/templates/authentication/login.html:9
5
msgid "Keycloak"
msgid "Keycloak"
msgstr ""
msgstr ""
...
@@ -2542,16 +2554,16 @@ msgstr "欢迎回来,请输入用户名和密码登录"
...
@@ -2542,16 +2554,16 @@ msgstr "欢迎回来,请输入用户名和密码登录"
msgid "Please enable cookies and try again."
msgid "Please enable cookies and try again."
msgstr "设置你的浏览器支持cookie"
msgstr "设置你的浏览器支持cookie"
#: authentication/views/login.py:17
2
users/views/user.py:386
#: authentication/views/login.py:17
3
users/views/user.py:386
#: users/views/user.py:411
#: users/views/user.py:411
msgid "MFA code invalid, or ntp sync server time"
msgid "MFA code invalid, or ntp sync server time"
msgstr "MFA验证码不正确,或者服务器端时间不对"
msgstr "MFA验证码不正确,或者服务器端时间不对"
#: authentication/views/login.py:20
3
#: authentication/views/login.py:20
4
msgid "Logout success"
msgid "Logout success"
msgstr "退出登录成功"
msgstr "退出登录成功"
#: authentication/views/login.py:20
4
#: authentication/views/login.py:20
5
msgid "Logout success, return login page"
msgid "Logout success, return login page"
msgstr "退出登录成功,返回到登录页面"
msgstr "退出登录成功,返回到登录页面"
...
@@ -2955,9 +2967,9 @@ msgstr "版本"
...
@@ -2955,9 +2967,9 @@ msgstr "版本"
#: ops/templates/ops/task_list.html:63
#: ops/templates/ops/task_list.html:63
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:137
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:137
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:5
3
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:5
4
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:141
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:141
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:5
4
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:5
5
msgid "Run"
msgid "Run"
msgstr "执行"
msgstr "执行"
...
@@ -3167,7 +3179,7 @@ msgstr "刷新授权缓存"
...
@@ -3167,7 +3179,7 @@ msgstr "刷新授权缓存"
msgid "Validity"
msgid "Validity"
msgstr "有效"
msgstr "有效"
#: perms/templates/perms/asset_permission_list.html:24
4
#: perms/templates/perms/asset_permission_list.html:24
5
msgid "Refresh success"
msgid "Refresh success"
msgstr "刷新成功"
msgstr "刷新成功"
...
@@ -4347,11 +4359,11 @@ msgstr "地址"
...
@@ -4347,11 +4359,11 @@ msgstr "地址"
msgid "Alive"
msgid "Alive"
msgstr "在线"
msgstr "在线"
#: terminal/templates/terminal/terminal_list.html:7
7
#: terminal/templates/terminal/terminal_list.html:7
8
msgid "Accept"
msgid "Accept"
msgstr "接受"
msgstr "接受"
#: terminal/templates/terminal/terminal_list.html:
79
#: terminal/templates/terminal/terminal_list.html:
80
msgid "Reject"
msgid "Reject"
msgstr "拒绝"
msgstr "拒绝"
...
@@ -4911,45 +4923,45 @@ msgstr "添加用户"
...
@@ -4911,45 +4923,45 @@ msgstr "添加用户"
msgid "Create user group"
msgid "Create user group"
msgstr "创建用户组"
msgstr "创建用户组"
#: users/templates/users/user_group_list.html:11
4
#: users/templates/users/user_group_list.html:11
5
msgid "This will delete the selected groups !!!"
msgid "This will delete the selected groups !!!"
msgstr "删除选择组"
msgstr "删除选择组"
#: users/templates/users/user_group_list.html:12
3
#: users/templates/users/user_group_list.html:12
4
msgid "UserGroups Deleted."
msgid "UserGroups Deleted."
msgstr "用户组删除"
msgstr "用户组删除"
#: users/templates/users/user_group_list.html:12
4
#: users/templates/users/user_group_list.html:12
5
#: users/templates/users/user_group_list.html:1
29
#: users/templates/users/user_group_list.html:1
30
msgid "UserGroups Delete"
msgid "UserGroups Delete"
msgstr "用户组删除"
msgstr "用户组删除"
#: users/templates/users/user_group_list.html:12
8
#: users/templates/users/user_group_list.html:12
9
msgid "UserGroup Deleting failed."
msgid "UserGroup Deleting failed."
msgstr "用户组删除失败"
msgstr "用户组删除失败"
#: users/templates/users/user_list.html:25
0
#: users/templates/users/user_list.html:25
1
msgid "This will delete the selected users !!!"
msgid "This will delete the selected users !!!"
msgstr "删除选中用户 !!!"
msgstr "删除选中用户 !!!"
#: users/templates/users/user_list.html:26
6
#: users/templates/users/user_list.html:26
7
msgid "User Deleted."
msgid "User Deleted."
msgstr "已被删除"
msgstr "已被删除"
#: users/templates/users/user_list.html:26
7
#: users/templates/users/user_list.html:26
8
#: users/templates/users/user_list.html:27
1
#: users/templates/users/user_list.html:27
2
msgid "User Delete"
msgid "User Delete"
msgstr "删除"
msgstr "删除"
#: users/templates/users/user_list.html:27
0
#: users/templates/users/user_list.html:27
1
msgid "User Deleting failed."
msgid "User Deleting failed."
msgstr "用户删除失败"
msgstr "用户删除失败"
#: users/templates/users/user_list.html:32
3
#: users/templates/users/user_list.html:32
4
msgid "User is expired"
msgid "User is expired"
msgstr "用户已失效"
msgstr "用户已失效"
#: users/templates/users/user_list.html:32
6
#: users/templates/users/user_list.html:32
7
msgid "User is inactive"
msgid "User is inactive"
msgstr "用户已禁用"
msgstr "用户已禁用"
...
@@ -5484,7 +5496,7 @@ msgid "Run plan manually"
...
@@ -5484,7 +5496,7 @@ msgid "Run plan manually"
msgstr "手动执行计划"
msgstr "手动执行计划"
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:179
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:179
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:10
2
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:10
3
msgid "Execute failed"
msgid "Execute failed"
msgstr "执行失败"
msgstr "执行失败"
...
@@ -5708,7 +5720,7 @@ msgid "Run task manually"
...
@@ -5708,7 +5720,7 @@ msgid "Run task manually"
msgstr "手动执行任务"
msgstr "手动执行任务"
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:181
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:181
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:9
8
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:9
9
msgid "Sync success"
msgid "Sync success"
msgstr "同步成功"
msgstr "同步成功"
...
...
apps/users/utils.py
View file @
3d9c0a21
...
@@ -299,6 +299,12 @@ def increase_login_failed_count(username, ip):
...
@@ -299,6 +299,12 @@ def increase_login_failed_count(username, ip):
cache
.
set
(
key_limit
,
count
,
int
(
limit_time
)
*
60
)
cache
.
set
(
key_limit
,
count
,
int
(
limit_time
)
*
60
)
def
get_login_failed_count
(
username
,
ip
):
key_limit
=
key_prefix_limit
.
format
(
username
,
ip
)
count
=
cache
.
get
(
key_limit
,
0
)
return
count
def
clean_failed_count
(
username
,
ip
):
def
clean_failed_count
(
username
,
ip
):
key_limit
=
key_prefix_limit
.
format
(
username
,
ip
)
key_limit
=
key_prefix_limit
.
format
(
username
,
ip
)
key_block
=
key_prefix_block
.
format
(
username
)
key_block
=
key_prefix_block
.
format
(
username
)
...
@@ -307,9 +313,8 @@ def clean_failed_count(username, ip):
...
@@ -307,9 +313,8 @@ def clean_failed_count(username, ip):
def
is_block_login
(
username
,
ip
):
def
is_block_login
(
username
,
ip
):
key_limit
=
key_prefix_limit
.
forma
t
(
username
,
ip
)
count
=
get_login_failed_coun
t
(
username
,
ip
)
key_block
=
key_prefix_block
.
format
(
username
)
key_block
=
key_prefix_block
.
format
(
username
)
count
=
cache
.
get
(
key_limit
,
0
)
limit_count
=
settings
.
SECURITY_LOGIN_LIMIT_COUNT
limit_count
=
settings
.
SECURITY_LOGIN_LIMIT_COUNT
limit_time
=
settings
.
SECURITY_LOGIN_LIMIT_TIME
limit_time
=
settings
.
SECURITY_LOGIN_LIMIT_TIME
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment