fix: otp 绑定问题

pull/6896/head
xinwen 2021-09-16 18:59:15 +08:00 committed by 老广
parent c26ca20ad8
commit b375cd3e75
3 changed files with 80 additions and 71 deletions

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: JumpServer 0.3.3\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-09-16 10:57+0800\n"
"POT-Creation-Date: 2021-09-16 18:58+0800\n"
"PO-Revision-Date: 2021-05-20 10:54+0800\n"
"Last-Translator: ibuler <ibuler@qq.com>\n"
"Language-Team: JumpServer team<ibuler@qq.com>\n"
@ -98,7 +98,7 @@ msgstr "动作"
#: terminal/backends/command/models.py:18
#: terminal/backends/command/serializers.py:12 terminal/models/session.py:38
#: tickets/models/comment.py:17 users/const.py:14 users/models/user.py:181
#: users/models/user.py:809 users/models/user.py:835
#: users/models/user.py:813 users/models/user.py:839
#: users/serializers/group.py:19
#: users/templates/users/user_asset_permission.html:38
#: users/templates/users/user_asset_permission.html:64
@ -281,7 +281,7 @@ msgstr "应用管理"
#: applications/serializers/application.py:88 assets/models/label.py:21
#: perms/models/application_permission.py:20
#: perms/serializers/application/user_permission.py:33
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:20
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:22
#: xpack/plugins/change_auth_plan/models/app.py:25
msgid "Category"
msgstr "类别"
@ -292,7 +292,7 @@ msgstr "类别"
#: perms/serializers/application/user_permission.py:34
#: terminal/models/storage.py:55 terminal/models/storage.py:116
#: tickets/models/flow.py:51 tickets/models/ticket.py:48
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:27
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:29
#: xpack/plugins/change_auth_plan/models/app.py:28
#: xpack/plugins/change_auth_plan/models/app.py:148
msgid "Type"
@ -310,7 +310,7 @@ msgstr ""
#: applications/serializers/application.py:59
#: applications/serializers/application.py:89 assets/serializers/label.py:13
#: perms/serializers/application/permission.py:16
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:24
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:26
msgid "Category display"
msgstr "类别名称"
@ -318,7 +318,7 @@ msgstr "类别名称"
#: applications/serializers/application.py:91
#: assets/serializers/system_user.py:26 audits/serializers.py:29
#: perms/serializers/application/permission.py:17
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:31
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:33
#: tickets/serializers/ticket/ticket.py:22
#: tickets/serializers/ticket/ticket.py:168
msgid "Type display"
@ -377,7 +377,7 @@ msgstr "目标URL"
#: applications/serializers/attrs/application_type/vmware_client.py:30
#: assets/models/base.py:177 audits/signals_handler.py:65
#: authentication/forms.py:22
#: authentication/templates/authentication/login.html:164
#: authentication/templates/authentication/login.html:165
#: settings/serializers/auth/ldap.py:44 users/forms/profile.py:21
#: users/templates/users/user_otp_check_password.html:13
#: users/templates/users/user_password_update.html:43
@ -544,7 +544,7 @@ msgstr "创建者"
#: assets/models/label.py:25 common/db/models.py:72 common/mixins/models.py:50
#: ops/models/adhoc.py:38 ops/models/command.py:29 orgs/models.py:26
#: orgs/models.py:435 perms/models/base.py:52 users/models/group.py:18
#: users/models/user.py:836 xpack/plugins/cloud/models.py:122
#: users/models/user.py:840 xpack/plugins/cloud/models.py:122
msgid "Date created"
msgstr "创建日期"
@ -625,7 +625,7 @@ msgid "Default"
msgstr "默认"
#: assets/models/cluster.py:36 assets/models/label.py:14
#: users/models/user.py:821
#: users/models/user.py:825
msgid "System"
msgstr "系统"
@ -1091,8 +1091,8 @@ msgstr "成功"
#: audits/models.py:43 ops/models/command.py:30 perms/models/base.py:49
#: terminal/models/session.py:52
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:53
#: tickets/serializers/ticket/meta/ticket_type/apply_asset.py:45
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:55
#: tickets/serializers/ticket/meta/ticket_type/apply_asset.py:47
#: xpack/plugins/change_auth_plan/models/base.py:105
#: xpack/plugins/change_auth_plan/models/base.py:189
#: xpack/plugins/gathered_user/models.py:76
@ -1239,13 +1239,13 @@ msgid "Auth Token"
msgstr "认证令牌"
#: audits/signals_handler.py:68
#: authentication/templates/authentication/login.html:210
#: authentication/templates/authentication/login.html:216
#: notifications/backends/__init__.py:11 users/models/user.py:659
msgid "WeCom"
msgstr "企业微信"
#: audits/signals_handler.py:69
#: authentication/templates/authentication/login.html:215
#: authentication/templates/authentication/login.html:221
#: notifications/backends/__init__.py:12 users/models/user.py:660
msgid "DingTalk"
msgstr "钉钉"
@ -1433,7 +1433,7 @@ msgstr "{ApplicationPermission} 添加 {SystemUser}"
msgid "{ApplicationPermission} REMOVE {SystemUser}"
msgstr "{ApplicationPermission} 移除 {SystemUser}"
#: authentication/api/connection_token.py:230
#: authentication/api/connection_token.py:227
msgid "Invalid token"
msgstr "无效的令牌"
@ -1764,30 +1764,30 @@ msgstr "代码错误"
msgid "Welcome back, please enter username and password to login"
msgstr "欢迎回来,请输入用户名和密码登录"
#: authentication/templates/authentication/login.html:183
#: authentication/templates/authentication/login.html:189
#: users/templates/users/forgot_password.html:15
#: users/templates/users/forgot_password.html:16
msgid "Forgot password"
msgstr "忘记密码"
#: authentication/templates/authentication/login.html:190
#: authentication/templates/authentication/login.html:196
#: templates/_header_bar.html:83
msgid "Login"
msgstr "登录"
#: authentication/templates/authentication/login.html:197
#: authentication/templates/authentication/login.html:203
msgid "More login options"
msgstr "更多登录方式"
#: authentication/templates/authentication/login.html:200
#: authentication/templates/authentication/login.html:206
msgid "OpenID"
msgstr "OpenID"
#: authentication/templates/authentication/login.html:205
#: authentication/templates/authentication/login.html:211
msgid "CAS"
msgstr "CAS"
#: authentication/templates/authentication/login.html:220
#: authentication/templates/authentication/login.html:226
#: notifications/backends/__init__.py:14 users/models/user.py:661
msgid "FeiShu"
msgstr "飞书"
@ -2342,22 +2342,22 @@ msgstr "任务结束"
msgid "Server performance"
msgstr "监控告警"
#: ops/notifications.py:40
#: ops/notifications.py:47
#, python-brace-format
msgid "The terminal is offline: {name}"
msgstr "终端已离线: {name}"
#: ops/notifications.py:46
#: ops/notifications.py:53
#, python-brace-format
msgid "[Disk] Disk used more than {max_threshold}%: => {value} ({name})"
msgstr "[Disk] 硬盘使用率超过 {max_threshold}%: => {value} ({name})"
#: ops/notifications.py:53
#: ops/notifications.py:60
#, python-brace-format
msgid "[Memory] Memory used more than {max_threshold}%: => {value} ({name})"
msgstr "[Memory] 内存使用率超过 {max_threshold}%: => {value} ({name})"
#: ops/notifications.py:60
#: ops/notifications.py:67
#, python-brace-format
msgid "[CPU] CPU load more than {max_threshold}: => {value} ({name})"
msgstr "[CPU] CPU 使用率超过 {max_threshold}: => {value} ({name})"
@ -2478,8 +2478,8 @@ msgid "User group"
msgstr "用户组"
#: perms/models/base.py:50
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:56
#: tickets/serializers/ticket/meta/ticket_type/apply_asset.py:48
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:58
#: tickets/serializers/ticket/meta/ticket_type/apply_asset.py:50
#: users/models/user.py:642
msgid "Date expired"
msgstr "失效日期"
@ -2583,7 +2583,7 @@ msgstr "成功导入 {} 个用户 ( 组织: {} )"
msgid "Welcome to the JumpServer open source Bastion Host"
msgstr "欢迎使用JumpServer开源堡垒机"
#: settings/models.py:155 users/templates/users/reset_password.html:29
#: settings/models.py:191 users/templates/users/reset_password.html:29
msgid "Setting"
msgstr "设置"
@ -4539,52 +4539,52 @@ msgstr "你有一个新的工单, 申请人 - {}"
msgid "Your ticket has been processed, processor - {}"
msgstr "你的工单已被处理, 处理人 - {}"
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:16
#: tickets/serializers/ticket/meta/ticket_type/apply_asset.py:16
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:18
#: tickets/serializers/ticket/meta/ticket_type/apply_asset.py:18
msgid "Apply name"
msgstr "应用名称"
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:35
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:37
msgid "Apply applications"
msgstr "申请应用"
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:40
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:42
msgid "Apply applications display"
msgstr "应用名称名称"
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:44
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:46
msgid "Apply system users"
msgstr "系统用户"
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:49
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:51
msgid "Apply system user display"
msgstr "批准的系统用户名称"
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:69
#: tickets/serializers/ticket/meta/ticket_type/apply_asset.py:61
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:71
#: tickets/serializers/ticket/meta/ticket_type/apply_asset.py:63
#: tickets/serializers/ticket/ticket.py:127
msgid "Permission named `{}` already exists"
msgstr "授权名称 `{}` 已存在"
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:75
#: tickets/serializers/ticket/meta/ticket_type/apply_asset.py:67
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:80
#: tickets/serializers/ticket/meta/ticket_type/apply_asset.py:72
msgid "The expiration date should be greater than the start date"
msgstr "过期时间要大于开始时间"
#: tickets/serializers/ticket/meta/ticket_type/apply_asset.py:20
#: tickets/serializers/ticket/meta/ticket_type/apply_asset.py:22
msgid "Apply assets"
msgstr "申请资产"
#: tickets/serializers/ticket/meta/ticket_type/apply_asset.py:24
#: tickets/serializers/ticket/meta/ticket_type/apply_asset.py:26
msgid "Approve assets display"
msgstr "批准的资产名称"
#: tickets/serializers/ticket/meta/ticket_type/apply_asset.py:29
#: tickets/serializers/ticket/meta/ticket_type/apply_asset.py:31
msgid "Approve system users"
msgstr "批准的系统用户"
#: tickets/serializers/ticket/meta/ticket_type/apply_asset.py:33
#: tickets/serializers/ticket/meta/ticket_type/apply_asset.py:41
#: tickets/serializers/ticket/meta/ticket_type/apply_asset.py:35
#: tickets/serializers/ticket/meta/ticket_type/apply_asset.py:43
msgid "Apply assets display"
msgstr "批准的资产名称"
@ -4799,21 +4799,21 @@ msgstr "最后更新密码日期"
msgid "Need update password"
msgstr "需要更新密码"
#: users/models/user.py:817
#: users/models/user.py:821
msgid "Administrator"
msgstr "管理员"
#: users/models/user.py:820
#: users/models/user.py:824
msgid "Administrator is the super user of system"
msgstr "Administrator是初始的超级管理员"
#: users/notifications.py:17 users/notifications.py:50
#: users/notifications.py:19 users/notifications.py:52
#: users/templates/users/reset_password.html:5
#: users/templates/users/reset_password.html:6
msgid "Reset password"
msgstr "重置密码"
#: users/notifications.py:18
#: users/notifications.py:20
#, python-format
msgid ""
"\n"
@ -4853,7 +4853,7 @@ msgstr ""
"%(login_url)s\n"
"\n"
#: users/notifications.py:51
#: users/notifications.py:53
#, python-format
msgid ""
"\n"
@ -4897,12 +4897,12 @@ msgstr ""
" <br>\n"
" "
#: users/notifications.py:90 users/notifications.py:122
#: users/notifications.py:92 users/notifications.py:124
#: users/views/profile/reset.py:127
msgid "Reset password success"
msgstr "重置密码成功"
#: users/notifications.py:91
#: users/notifications.py:93
#, python-format
msgid ""
"\n"
@ -4948,7 +4948,7 @@ msgstr ""
" \n"
" "
#: users/notifications.py:123
#: users/notifications.py:125
#, python-format
msgid ""
"\n"
@ -5011,11 +5011,11 @@ msgstr ""
" \n"
" "
#: users/notifications.py:166 users/notifications.py:202
#: users/notifications.py:170 users/notifications.py:206
msgid "Security notice"
msgstr "安全通知"
#: users/notifications.py:167
#: users/notifications.py:171
#, python-format
msgid ""
"\n"
@ -5059,7 +5059,7 @@ msgstr ""
"\n"
" "
#: users/notifications.py:203
#: users/notifications.py:207
#, python-format
msgid ""
"\n"
@ -5108,11 +5108,11 @@ msgstr ""
" <br>\n"
" "
#: users/notifications.py:240 users/notifications.py:259
#: users/notifications.py:244 users/notifications.py:263
msgid "Expiration notice"
msgstr "过期通知"
#: users/notifications.py:241
#: users/notifications.py:245
#, python-format
msgid ""
"\n"
@ -5133,7 +5133,7 @@ msgstr ""
"为了不影响您正常工作,请联系管理员确认。\n"
" "
#: users/notifications.py:260
#: users/notifications.py:264
#, python-format
msgid ""
"\n"
@ -5155,11 +5155,11 @@ msgstr ""
" <br>\n"
" "
#: users/notifications.py:280 users/notifications.py:301
#: users/notifications.py:284 users/notifications.py:305
msgid "SSH Key Reset"
msgstr "重置SSH密钥"
#: users/notifications.py:281
#: users/notifications.py:285
#, python-format
msgid ""
"\n"
@ -5184,7 +5184,7 @@ msgstr ""
"\n"
" "
#: users/notifications.py:302
#: users/notifications.py:306
#, python-format
msgid ""
"\n"
@ -5209,11 +5209,11 @@ msgstr ""
" <br>\n"
" "
#: users/notifications.py:324 users/notifications.py:344
#: users/notifications.py:328 users/notifications.py:348
msgid "MFA Reset"
msgstr "重置 MFA"
#: users/notifications.py:325
#: users/notifications.py:329
#, python-format
msgid ""
"\n"
@ -5238,7 +5238,7 @@ msgstr ""
"\n"
" "
#: users/notifications.py:345
#: users/notifications.py:349
#, python-format
msgid ""
"\n"
@ -5267,7 +5267,7 @@ msgstr ""
msgid "The old password is incorrect"
msgstr "旧密码错误"
#: users/serializers/profile.py:36 users/serializers/user.py:140
#: users/serializers/profile.py:36 users/serializers/user.py:141
msgid "Password does not match security rules"
msgstr "密码不满足安全规则"
@ -5353,11 +5353,15 @@ msgstr "是否绑定了钉钉"
msgid "Is feishu bound"
msgstr "是否绑定了飞书"
#: users/serializers/user.py:114
#: users/serializers/user.py:91
msgid "Is OTP bound"
msgstr "是否绑定了虚拟MFA"
#: users/serializers/user.py:115
msgid "Role limit to {}"
msgstr "角色只能为 {}"
#: users/serializers/user.py:234
#: users/serializers/user.py:235
msgid "name not unique"
msgstr "名称重复"
@ -5678,7 +5682,7 @@ msgstr "* 新密码不能是最近 {} 次的密码"
msgid "Reset password success, return to login page"
msgstr "重置密码成功,返回到登录页面"
#: xpack/plugins/change_auth_plan/api/app.py:113
#: xpack/plugins/change_auth_plan/api/app.py:112
#: xpack/plugins/change_auth_plan/api/asset.py:100
msgid "The parameter 'action' must be [{}]"
msgstr "参数 'action' 必须是 [{}]"
@ -6126,16 +6130,16 @@ msgstr "租户 ID"
msgid "Subscription ID"
msgstr "订阅 ID"
#: xpack/plugins/cloud/serializers/account_attrs.py:87
#: xpack/plugins/cloud/serializers/account_attrs.py:92
#: xpack/plugins/cloud/serializers/account_attrs.py:81
#: xpack/plugins/cloud/serializers/account_attrs.py:86
msgid "API Endpoint"
msgstr "API 端点"
#: xpack/plugins/cloud/serializers/account_attrs.py:98
#: xpack/plugins/cloud/serializers/account_attrs.py:92
msgid "Service account key"
msgstr "账户密钥"
#: xpack/plugins/cloud/serializers/account_attrs.py:99
#: xpack/plugins/cloud/serializers/account_attrs.py:93
msgid "The file is in JSON format"
msgstr "JSON 格式的文件"

View File

@ -685,6 +685,10 @@ class User(AuthMixin, TokenMixin, RoleMixin, MFAMixin, AbstractUser):
def is_feishu_bound(self):
return bool(self.feishu_id)
@property
def is_otp_secret_key_bound(self):
return bool(self.otp_secret_key)
def get_absolute_url(self):
return reverse('users:user-detail', args=(self.id,))

View File

@ -51,7 +51,7 @@ class UserSerializer(CommonBulkSerializerMixin, serializers.ModelSerializer):
'mfa_enabled', 'is_valid', 'is_expired', 'is_active', # 布尔字段
'date_expired', 'date_joined', 'last_login', # 日期字段
'created_by', 'comment', # 通用字段
'is_wecom_bound', 'is_dingtalk_bound', 'is_feishu_bound',
'is_wecom_bound', 'is_dingtalk_bound', 'is_feishu_bound', 'is_otp_secret_key_bound',
'wecom_id', 'dingtalk_id', 'feishu_id'
]
# 包含不太常用的字段,可以没有
@ -88,6 +88,7 @@ class UserSerializer(CommonBulkSerializerMixin, serializers.ModelSerializer):
'is_wecom_bound': {'label': _('Is wecom bound')},
'is_dingtalk_bound': {'label': _('Is dingtalk bound')},
'is_feishu_bound': {'label': _('Is feishu bound')},
'is_otp_secret_key_bound': {'label': _('Is OTP bound')},
'phone': {'validators': [PhoneValidator()]},
}