diff --git a/src/i18n/langs/cn.json b/src/i18n/langs/cn.json index 3a0397279..958adb7a8 100644 --- a/src/i18n/langs/cn.json +++ b/src/i18n/langs/cn.json @@ -197,7 +197,9 @@ }, "updateErrorMsg": "更新失败", "updateSelected": "更新所选", - "updateSuccessMsg": "更新成功" + "updateSuccessMsg": "更新成功", + "Disable": "禁用", + "Enable": "启用" }, "dashboard": { "ActiveAsset": "近期被登录过", diff --git a/src/layout/components/NavHeader/AccountDropdown.vue b/src/layout/components/NavHeader/AccountDropdown.vue index d8ceeeb7d..2c2f0ca04 100644 --- a/src/layout/components/NavHeader/AccountDropdown.vue +++ b/src/layout/components/NavHeader/AccountDropdown.vue @@ -54,7 +54,7 @@ export default { handleClick(val) { switch (val) { case 'profile': - this.$router.push({ name: 'userProfile' }) + this.$router.push({ name: 'UserProfile' }) break case 'AdminPage': setPermission('Admin') diff --git a/src/router/index.js b/src/router/index.js index 40356ef63..684971d69 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -65,8 +65,8 @@ export const commonRoutes = { children: [ { path: '', - name: 'userProfile', - component: () => import('@/userviews/users/index'), + name: 'UserProfile', + component: () => import('@/userviews/users/UserProfile/index'), meta: { title: i18n.t('route.UserProfile'), icon: 'user', activeMenu: '/users/profile' } } ] diff --git a/src/userviews/users/UserProfile/PasswordUpdate.vue b/src/userviews/users/UserProfile/PasswordUpdate.vue new file mode 100644 index 000000000..df412652f --- /dev/null +++ b/src/userviews/users/UserProfile/PasswordUpdate.vue @@ -0,0 +1,65 @@ + + + + + diff --git a/src/userviews/users/UserProfile.vue b/src/userviews/users/UserProfile/ProfileInfo.vue similarity index 75% rename from src/userviews/users/UserProfile.vue rename to src/userviews/users/UserProfile/ProfileInfo.vue index 83b557e63..8a1bf2d1d 100644 --- a/src/userviews/users/UserProfile.vue +++ b/src/userviews/users/UserProfile/ProfileInfo.vue @@ -14,7 +14,7 @@ import DetailCard from '@/components/DetailCard' import QuickActions from '@/components/QuickActions' import { toSafeLocalDateStr } from '@/utils/common' export default { - name: 'UserProfile', + name: 'ProfileInfo', components: { DetailCard, QuickActions @@ -27,47 +27,37 @@ export default { }, data() { return { + url: `/api/v1/users/profile/`, quickActions: [ { title: this.$t('assets.SetMFA'), attrs: { type: 'primary', - label: this.$t('common.Reset') + label: this.object.mfa_enabled ? this.$t('common.Disable') : this.$t('common.Enable'), + disabled: this.object.mfa_force_enabled }, callbacks: { - click: function() {} + click: function() { + if (this.object.mfa_enabled) { + if (!this.object.mfa_force_enabled) { + window.location.href = `/users/profile/otp/disable/authentication/?next=${this.$route.fullPath}` + } + } else { + window.location.href = `/users/profile/otp/enable/start/?next=${this.$route.fullPath}` + } + }.bind(this) } }, { title: this.$t('assets.UpdateMFA'), - attrs: { - type: 'primary', - label: this.$t('common.Reset') - }, - callbacks: { - click: function() {} - } - }, - { - title: this.$t('assets.UpdatePassword'), attrs: { type: 'primary', label: this.$t('common.Update') }, callbacks: { click: function() { - - } - } - }, - { - title: this.$t('assets.UpdateSSHPublicKey'), - attrs: { - type: 'primary', - label: this.$t('common.Update') - }, - callbacks: { - click: function() {} + window.location.href = `/users/profile/otp/update/?next=${this.$route.fullPath}` + }.bind(this) } }, { @@ -77,7 +67,9 @@ export default { label: this.$t('common.Reset') }, callbacks: { - click: function() {} + click: function() { + window.open(`/users/profile/pubkey/generate/`, '_blank') + } } } ] @@ -107,8 +99,8 @@ export default { key: this.$t('assets.IsActive') }, { - value: `没有这个API`, - key: this.$t('assets.sshkey') + value: `${this.object.public_key_comment} ${this.object.public_key_hash_md5}`, + key: 'SSHKey' }, { value: this.object.mfa_level_display, diff --git a/src/userviews/users/UserProfile/ProfileUpdate.vue b/src/userviews/users/UserProfile/ProfileUpdate.vue new file mode 100644 index 000000000..72018cf79 --- /dev/null +++ b/src/userviews/users/UserProfile/ProfileUpdate.vue @@ -0,0 +1,59 @@ + + + + + diff --git a/src/userviews/users/UserProfile/SSHUpdate.vue b/src/userviews/users/UserProfile/SSHUpdate.vue new file mode 100644 index 000000000..9fba19c2a --- /dev/null +++ b/src/userviews/users/UserProfile/SSHUpdate.vue @@ -0,0 +1,74 @@ + + + + + diff --git a/src/userviews/users/index.vue b/src/userviews/users/UserProfile/index.vue similarity index 52% rename from src/userviews/users/index.vue rename to src/userviews/users/UserProfile/index.vue index 0c71c3b2d..cb0ac3c7c 100644 --- a/src/userviews/users/index.vue +++ b/src/userviews/users/UserProfile/index.vue @@ -8,22 +8,41 @@