Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "feature: admin账户重置密码需要先输入原密码进行校验 #811" #852

Merged
merged 1 commit into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/pages/src/language/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ export default {
修复: '【FIX】',
优化: '【OPTIMIZATION】',
// 密码
原密码: 'Old Password',
重置密码: 'Reset Password',
密码长度为: 'Password length is',
'-32个字符,必须包含': '-32 characters, it must be included',
Expand All @@ -188,7 +187,6 @@ export default {
'两次输入的密码不一致,请重新输入': 'The passwords entered twice do not match. Please re-enter them',
设置新密码: 'Set new password',
请输入新密码进行密码重设: 'Please enter a new password for password reset',
请输入原密码: 'Please enter old password',
请输入新密码: 'Please enter a new password',
请再次确认新密码: 'Please confirm the new password again',
密码修改成功: 'Password changed successfully',
Expand Down
2 changes: 0 additions & 2 deletions src/pages/src/language/lang/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ export default {
修复: '【修复】',
优化: '【优化】',
// 密码
原密码: '原密码',
重置密码: '重置密码',
密码长度为: '密码长度为',
'-32个字符,必须包含': '-32个字符,必须包含',
Expand All @@ -188,7 +187,6 @@ export default {
'两次输入的密码不一致,请重新输入': '两次输入的密码不一致,请重新输入',
设置新密码: '设置新密码',
请输入新密码进行密码重设: '请输入新密码进行密码重设',
请输入原密码: '请输入原密码',
请输入新密码: '请输入新密码',
请再次确认新密码: '请再次确认新密码',
密码修改成功: '密码修改成功',
Expand Down
64 changes: 9 additions & 55 deletions src/pages/src/views/organization/details/UserMaterial.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,35 +51,20 @@
</bk-button>
<div class="reset-dialog" v-if="isShowReset" v-click-outside="closeResetDialog">
<i class="arrow"></i>
<template v-if="isAdmin">
<h4 class="title">{{$t('原密码')}}</h4>
<p class="pw-input-text">
<input
autocomplete="old-password"
:type="passwordInputType['oldPassword']"
:placeholder="$t('请输入原密码')"
:class="['editor-password',{ 'input-error': isCorrectOldPw }]"
:maxlength="32"
v-model="oldPassword"
v-focus
@focus="isCorrectOldPw = false" />
<i :class="['bk-icon', oldPasswordIconClass]" @click="changePasswordInputType('oldPassword')"></i>
</p>
</template>
<h4 class="title">{{$t('重置密码')}}</h4>
<p class="pw-input-text">
<input type="text" class="hidden-password-input">
<input type="password" class="hidden-password-input">
<input
autocomplete="new-password"
:type="passwordInputType['newPassword']"
:type="passwordInputType"
:placeholder="$t('请输入新密码')"
:class="['editor-password',{ 'input-error': isCorrectPw }]"
:maxlength="32"
v-model="newPassword"
v-focus
@focus="isCorrectPw = false" />
<i :class="['bk-icon', passwordIconClass]" @click="changePasswordInputType('newPassword')"></i>
<i :class="['bk-icon', passwordIconClass]" @click="changePasswordInputType"></i>
</p>
<div class="reset-btn">
<bk-button theme="primary" class="editor-btn" @click="confirmReset">{{$t('确认')}}</bk-button>
Expand Down Expand Up @@ -189,16 +174,11 @@ export default {
localAvatar: '',
isForbid: false,
phoneNumber: this.$t('点击查看'),
isCorrectOldPw: false,
isCorrectPw: false,
// 是否显示重置密码的弹窗
isShowReset: false,
oldPassword: '',
newPassword: '',
passwordInputType: {
oldPassword: 'password',
newPassword: 'password',
},
passwordInputType: 'password',
passwordRules: null,
};
},
Expand All @@ -208,11 +188,8 @@ export default {
return fieldInfo.key !== 'department_name' && fieldInfo.key !== 'leader';
});
},
oldPasswordIconClass() {
return this.passwordInputType.oldPassword === 'password' ? 'icon-hide' : 'icon-eye';
},
passwordIconClass() {
return this.passwordInputType.newPassword === 'password' ? 'icon-hide' : 'icon-eye';
return this.passwordInputType === 'password' ? 'icon-hide' : 'icon-eye';
},
passwordValidDays() {
return this.$store.state.passwordValidDaysList.find(item => (
Expand Down Expand Up @@ -309,9 +286,6 @@ export default {
return;
}
this.isShowReset = true;
// 清空上次输入
this.oldPassword = '';
this.newPassword = '';
},
// 验证密码的格式
async confirmReset() {
Expand Down Expand Up @@ -347,18 +321,6 @@ export default {
}
if (this.passwordRules) {
// 如果上面拿到了规则就进行前端校验
// 原密码校验, 任何人在重置admin密码时,需要先输入原密码
if (this.isAdmin) {
this.isCorrectOldPw = !this.$validatePassportByRules(this.oldPassword, this.passwordRules);
if (this.isCorrectOldPw) {
this.$bkMessage({
message: this.$getMessageByRules(this, this.passwordRules),
theme: 'error',
});
return;
}
}
// 新密码校验
this.isCorrectPw = !this.$validatePassportByRules(this.newPassword, this.passwordRules);
if (this.isCorrectPw) {
this.$bkMessage({
Expand All @@ -374,16 +336,11 @@ export default {
this.clickSecond = true;
try {
this.$emit('showBarLoading');
const passwordData = {
password: this.newPassword.trim(),
};
// 任何人在重置admin密码时,需要先输入原密码
if (this.isAdmin) {
passwordData.old_password = this.oldPassword.trim();
};
await this.$store.dispatch('organization/patchProfile', {
id: this.currentProfile.id,
data: passwordData,
data: {
password: this.newPassword.trim(),
},
});
this.$bkMessage({
message: this.$t('重置密码成功'),
Expand All @@ -400,13 +357,10 @@ export default {
closeResetDialog(e) {
if (e.target.innerText === '重置密码') return;
this.isShowReset = false;
// 清空
this.oldPassword = '';
this.newPassword = '';
},
// 查看密码
changePasswordInputType(type = 'newPassword') {
this.passwordInputType[type] = this.passwordInputType[type] === 'password' ? 'text' : 'password';
changePasswordInputType() {
this.passwordInputType = this.passwordInputType === 'password' ? 'text' : 'password';
},
handleLoadAvatarError() {
this.localAvatar = this.$store.state.localAvatar;
Expand Down