diff --git a/nezha-fronted/src/components/common/language/cn.js b/nezha-fronted/src/components/common/language/cn.js index be4175997..473f0b1e8 100644 --- a/nezha-fronted/src/components/common/language/cn.js +++ b/nezha-fronted/src/components/common/language/cn.js @@ -721,7 +721,11 @@ const cn = { confirmPinErr: '两次密码输入不一致', reinputPin: '请再次输入密码', notification: '通知', - mobile: '电话' + mobile: '电话', + disable: '关闭', + enableMfa: '开启', + forceEnable: '强制开启', + mfaTitle: 'Two-Factor Authentication' }, roles: { roles: '角色', diff --git a/nezha-fronted/src/components/common/language/en.js b/nezha-fronted/src/components/common/language/en.js index e77bdb00d..dc1a3cbf1 100644 --- a/nezha-fronted/src/components/common/language/en.js +++ b/nezha-fronted/src/components/common/language/en.js @@ -730,7 +730,11 @@ const en = { confirmPinErr: 'The two passwords are inconsistent', reinputPin: 'Enter password again', notification: 'Notification', - mobile: 'Mobile' + mobile: 'Mobile', + disable: 'Disable', + enableMfa: 'EnableMfa', + forceEnable: 'ForceEnable', + mfaTitle: 'Two-Factor Authentication' }, roles: { roles: 'Role', diff --git a/nezha-fronted/src/components/common/login.vue b/nezha-fronted/src/components/common/login.vue index bc30a00cd..64989c419 100644 --- a/nezha-fronted/src/components/common/login.vue +++ b/nezha-fronted/src/components/common/login.vue @@ -164,10 +164,10 @@ export default { this.$post('sys/login', this.loginData).then(res => { if (res.code == 200) { // 登录成功,记录用户名、token和lang - // res.data.authFlag = 1 + // res.data.authFlag = 0 // res.data.authBind = 1 this.authToken = res.data.token - sessionStorage.setItem('nz-token', this.authToken) + sessionStorage.setItem('nz-token', res.data.token) if (res.data.authFlag === 1) { if (res.data.authBind === 0) { this.verifyShow = true @@ -176,8 +176,8 @@ export default { this.dialogLoading = true this.$post('mfa/genKey', { authToken: this.authToken }).then(res => { this.$nextTick(() => { - this.authToken = res.data.token - sessionStorage.setItem('nz-token', this.authToken) + this.authToken = res.data.authToken + // sessionStorage.setItem('nz-token', this.authToken) this.authKey = res.data.authKey this.bindQRCode(res.data.otpauth) }) @@ -208,12 +208,17 @@ export default { authCode: this.loginData.authCode } this.$post('mfa/verify', params).then(res => { - sessionStorage.setItem('nz-username', this.loginData.username) - localStorage.setItem('nz-username', this.loginData.username) - localStorage.setItem('nz-prometheus-federation-enabled', res.data.prometheusFederationEnabled) - localStorage.setItem('nz-language', this.lang) - this.$i18n.locale = this.lang - this.loginSuccess(res) + if (res.code === 200) { + res.data.token = res.data.authToken + sessionStorage.setItem('nz-username', this.loginData.username) + localStorage.setItem('nz-username', this.loginData.username) + localStorage.setItem('nz-prometheus-federation-enabled', res.data.prometheusFederationEnabled) + localStorage.setItem('nz-language', this.lang) + this.$i18n.locale = this.lang + this.loginSuccess(res) + } else { + this.authToken = res.data.authToken + } }) }, changeLang (lang) { @@ -285,7 +290,7 @@ export default { bindCode () { this.prevent_opt.save = true this.$post('mfa/bind', { authToken: this.authToken, authCode: this.authCode }).then(res => { - this.prevent_opt.save = false + this.prevent_opt.save = false if (res.code === 200) { this.authBindShow = false this.bindAuthCode = '' diff --git a/nezha-fronted/src/components/common/rightBox/administration/userBox.vue b/nezha-fronted/src/components/common/rightBox/administration/userBox.vue index 0d9f9b756..81f8b4ac6 100644 --- a/nezha-fronted/src/components/common/rightBox/administration/userBox.vue +++ b/nezha-fronted/src/components/common/rightBox/administration/userBox.vue @@ -29,6 +29,21 @@ + + + + + + @@ -151,7 +166,12 @@ export default { { type: 'email', message: this.$t('validate.email') } ] }, - roles: [] + roles: [], + mfaLevelList: [ + { value: 0, label: this.$t('config.user.disable') }, + { value: 1, label: this.$t('config.user.enableMfa') }, + { value: 2, label: this.$t('config.user.forceEnable') } + ] } }, watch: { diff --git a/nezha-fronted/src/components/common/table/settings/userTable.vue b/nezha-fronted/src/components/common/table/settings/userTable.vue index a7fd36aab..bda055b8e 100644 --- a/nezha-fronted/src/components/common/table/settings/userTable.vue +++ b/nezha-fronted/src/components/common/table/settings/userTable.vue @@ -34,7 +34,13 @@