refactor: cas 不允许修改密码
This commit is contained in:
parent
f666b140bb
commit
0516111190
|
@ -4,7 +4,7 @@
|
|||
<template v-slot:header>
|
||||
<div>
|
||||
<el-row type="flex" just ify="space-between" align="middle">
|
||||
<span class="title">{{$t('commons.personal_info')}}</span>
|
||||
<span class="title">{{ $t('commons.personal_info') }}</span>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -24,7 +24,7 @@
|
|||
<template v-slot:default="scope">
|
||||
<ms-table-operator-button :tip="$t('member.edit_information')" icon="el-icon-edit"
|
||||
type="primary" @exec="edit(scope.row)"/>
|
||||
<ms-table-operator-button :tip="$t('member.edit_password')" icon="el-icon-s-tools" v-if="!isLdapUser"
|
||||
<ms-table-operator-button :tip="$t('member.edit_password')" icon="el-icon-s-tools" v-if="isLocalUser"
|
||||
type="success" @exec="editPassword(scope.row)"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
@ -43,7 +43,7 @@
|
|||
<el-input v-model="form.name" autocomplete="off"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('commons.email')" prop="email">
|
||||
<el-input v-model="form.email" autocomplete="off" :disabled="isLdapUser"/>
|
||||
<el-input v-model="form.email" autocomplete="off" :disabled="!isLocalUser"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('commons.phone')" prop="phone">
|
||||
<el-input v-model="form.phone" autocomplete="off"/>
|
||||
|
@ -82,159 +82,159 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {TokenKey} from "../../../../common/js/constants";
|
||||
import MsDialogFooter from "../../common/components/MsDialogFooter";
|
||||
import {getCurrentUser, listenGoBack, removeGoBackListener} from "../../../../common/js/utils";
|
||||
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
|
||||
import {PHONE_REGEX} from "@/common/js/regex";
|
||||
import {TokenKey} from "../../../../common/js/constants";
|
||||
import MsDialogFooter from "../../common/components/MsDialogFooter";
|
||||
import {getCurrentUser, listenGoBack, removeGoBackListener} from "../../../../common/js/utils";
|
||||
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
|
||||
import {PHONE_REGEX} from "@/common/js/regex";
|
||||
|
||||
export default {
|
||||
name: "MsPersonSetting",
|
||||
components: {MsDialogFooter, MsTableOperatorButton},
|
||||
data() {
|
||||
return {
|
||||
result: {},
|
||||
isLdapUser: false,
|
||||
updateVisible: false,
|
||||
editPasswordVisible: false,
|
||||
tableData: [],
|
||||
updatePath: '/user/update/current',
|
||||
updatePasswordPath: '/user/update/password',
|
||||
form: {},
|
||||
ruleForm: {},
|
||||
rule: {
|
||||
name: [
|
||||
{required: true, message: this.$t('member.input_name'), trigger: 'blur'},
|
||||
{min: 2, max: 20, message: this.$t('commons.input_limit', [2, 20]), trigger: 'blur'},
|
||||
{
|
||||
required: true,
|
||||
pattern: /^[\u4e00-\u9fa5_a-zA-Z0-9.·-]+$/,
|
||||
message: this.$t('member.special_characters_are_not_supported'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
phone: [
|
||||
{required: true, message: this.$t('user.input_phone'), trigger: 'blur'},
|
||||
{
|
||||
required: false,
|
||||
pattern: PHONE_REGEX,
|
||||
message: this.$t('member.mobile_number_format_is_incorrect'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
email: [
|
||||
{required: true, message: this.$t('member.input_email'), trigger: 'blur'},
|
||||
{
|
||||
required: true,
|
||||
pattern: /^([A-Za-z0-9_\-.])+@([A-Za-z0-9]+\.)+[A-Za-z]{2,6}$/,
|
||||
message: this.$t('member.email_format_is_incorrect'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
},
|
||||
rules:{
|
||||
password: [
|
||||
{required: true, message: this.$t('user.input_password'), trigger: 'blur'},
|
||||
],
|
||||
newpassword: [
|
||||
{required: true, message: this.$t('user.input_password'), trigger: 'blur'},
|
||||
{
|
||||
required: true,
|
||||
pattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,30}$/,
|
||||
message: this.$t('member.password_format_is_incorrect'),
|
||||
trigger: 'blur'
|
||||
},
|
||||
],
|
||||
repeatPassword: [
|
||||
{required: true, message: this.$t('user.input_password'), trigger: 'blur'},
|
||||
{
|
||||
required: true,
|
||||
pattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,30}$/,
|
||||
message: this.$t('member.password_format_is_incorrect'),
|
||||
trigger: 'blur'
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
activated() {
|
||||
this.initTableData();
|
||||
},
|
||||
methods: {
|
||||
currentUser: () => {
|
||||
return getCurrentUser();
|
||||
},
|
||||
edit(row) {
|
||||
this.updateVisible = true;
|
||||
this.form = Object.assign({}, row);
|
||||
listenGoBack(this.handleClose);
|
||||
},
|
||||
editPassword(row) {
|
||||
this.editPasswordVisible = true;
|
||||
listenGoBack(this.handleClose);
|
||||
},
|
||||
cancel(){
|
||||
this.editPasswordVisible = false;
|
||||
this.ruleForm.password="";
|
||||
this.ruleForm.newpassword="";
|
||||
},
|
||||
closeDialog(){
|
||||
this.editPasswordVisible = false;
|
||||
this.ruleForm.password="";
|
||||
this.ruleForm.newpassword="";
|
||||
},
|
||||
updateUser(updateUserForm) {
|
||||
this.$refs[updateUserForm].validate(valid => {
|
||||
if (valid) {
|
||||
this.result = this.$post(this.updatePath, this.form, response => {
|
||||
this.$success(this.$t('commons.modify_success'));
|
||||
localStorage.setItem(TokenKey, JSON.stringify(response.data));
|
||||
this.updateVisible = false;
|
||||
this.initTableData();
|
||||
window.location.reload();
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
export default {
|
||||
name: "MsPersonSetting",
|
||||
components: {MsDialogFooter, MsTableOperatorButton},
|
||||
data() {
|
||||
return {
|
||||
result: {},
|
||||
isLocalUser: false,
|
||||
updateVisible: false,
|
||||
editPasswordVisible: false,
|
||||
tableData: [],
|
||||
updatePath: '/user/update/current',
|
||||
updatePasswordPath: '/user/update/password',
|
||||
form: {},
|
||||
ruleForm: {},
|
||||
rule: {
|
||||
name: [
|
||||
{required: true, message: this.$t('member.input_name'), trigger: 'blur'},
|
||||
{min: 2, max: 20, message: this.$t('commons.input_limit', [2, 20]), trigger: 'blur'},
|
||||
{
|
||||
required: true,
|
||||
pattern: /^[\u4e00-\u9fa5_a-zA-Z0-9.·-]+$/,
|
||||
message: this.$t('member.special_characters_are_not_supported'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
})
|
||||
},
|
||||
updatePassword(editPasswordForm) {
|
||||
this.$refs[editPasswordForm].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.ruleForm.newpassword !== this.ruleForm.repeatPassword) {
|
||||
this.$warning(this.$t('member.inconsistent_passwords'));
|
||||
return;
|
||||
}
|
||||
this.result = this.$post(this.updatePasswordPath, this.ruleForm, response => {
|
||||
this.$success(this.$t('commons.modify_success'));
|
||||
this.editPasswordVisible = false;
|
||||
this.initTableData();
|
||||
window.location.reload();
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
],
|
||||
phone: [
|
||||
{required: true, message: this.$t('user.input_phone'), trigger: 'blur'},
|
||||
{
|
||||
required: false,
|
||||
pattern: PHONE_REGEX,
|
||||
message: this.$t('member.mobile_number_format_is_incorrect'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
})
|
||||
],
|
||||
email: [
|
||||
{required: true, message: this.$t('member.input_email'), trigger: 'blur'},
|
||||
{
|
||||
required: true,
|
||||
pattern: /^([A-Za-z0-9_\-.])+@([A-Za-z0-9]+\.)+[A-Za-z]{2,6}$/,
|
||||
message: this.$t('member.email_format_is_incorrect'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
},
|
||||
initTableData() {
|
||||
this.result = this.$get("/user/info/" + encodeURIComponent(this.currentUser().id), response => {
|
||||
let data = response.data;
|
||||
this.isLdapUser = response.data.source === 'LDAP' ? true : false;
|
||||
let dataList = [];
|
||||
dataList[0] = data;
|
||||
this.tableData = dataList;
|
||||
})
|
||||
},
|
||||
handleClose() {
|
||||
this.form = {};
|
||||
this.ruleForm = {};
|
||||
removeGoBackListener(this.handleClose);
|
||||
this.editPasswordVisible = false;
|
||||
this.updateVisible = false;
|
||||
rules: {
|
||||
password: [
|
||||
{required: true, message: this.$t('user.input_password'), trigger: 'blur'},
|
||||
],
|
||||
newpassword: [
|
||||
{required: true, message: this.$t('user.input_password'), trigger: 'blur'},
|
||||
{
|
||||
required: true,
|
||||
pattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,30}$/,
|
||||
message: this.$t('member.password_format_is_incorrect'),
|
||||
trigger: 'blur'
|
||||
},
|
||||
],
|
||||
repeatPassword: [
|
||||
{required: true, message: this.$t('user.input_password'), trigger: 'blur'},
|
||||
{
|
||||
required: true,
|
||||
pattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,30}$/,
|
||||
message: this.$t('member.password_format_is_incorrect'),
|
||||
trigger: 'blur'
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
activated() {
|
||||
this.initTableData();
|
||||
},
|
||||
methods: {
|
||||
currentUser: () => {
|
||||
return getCurrentUser();
|
||||
},
|
||||
edit(row) {
|
||||
this.updateVisible = true;
|
||||
this.form = Object.assign({}, row);
|
||||
listenGoBack(this.handleClose);
|
||||
},
|
||||
editPassword(row) {
|
||||
this.editPasswordVisible = true;
|
||||
listenGoBack(this.handleClose);
|
||||
},
|
||||
cancel() {
|
||||
this.editPasswordVisible = false;
|
||||
this.ruleForm.password = "";
|
||||
this.ruleForm.newpassword = "";
|
||||
},
|
||||
closeDialog() {
|
||||
this.editPasswordVisible = false;
|
||||
this.ruleForm.password = "";
|
||||
this.ruleForm.newpassword = "";
|
||||
},
|
||||
updateUser(updateUserForm) {
|
||||
this.$refs[updateUserForm].validate(valid => {
|
||||
if (valid) {
|
||||
this.result = this.$post(this.updatePath, this.form, response => {
|
||||
this.$success(this.$t('commons.modify_success'));
|
||||
localStorage.setItem(TokenKey, JSON.stringify(response.data));
|
||||
this.updateVisible = false;
|
||||
this.initTableData();
|
||||
window.location.reload();
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
},
|
||||
updatePassword(editPasswordForm) {
|
||||
this.$refs[editPasswordForm].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.ruleForm.newpassword !== this.ruleForm.repeatPassword) {
|
||||
this.$warning(this.$t('member.inconsistent_passwords'));
|
||||
return;
|
||||
}
|
||||
this.result = this.$post(this.updatePasswordPath, this.ruleForm, response => {
|
||||
this.$success(this.$t('commons.modify_success'));
|
||||
this.editPasswordVisible = false;
|
||||
this.initTableData();
|
||||
window.location.reload();
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
},
|
||||
initTableData() {
|
||||
this.result = this.$get("/user/info/" + encodeURIComponent(this.currentUser().id), response => {
|
||||
let data = response.data;
|
||||
this.isLocalUser = response.data.source === 'LOCAL';
|
||||
let dataList = [];
|
||||
dataList[0] = data;
|
||||
this.tableData = dataList;
|
||||
})
|
||||
},
|
||||
handleClose() {
|
||||
this.form = {};
|
||||
this.ruleForm = {};
|
||||
removeGoBackListener(this.handleClose);
|
||||
this.editPasswordVisible = false;
|
||||
this.updateVisible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<ms-table-operator @editClick="edit(scope.row)" @deleteClick="del(scope.row)">
|
||||
<template v-slot:behind>
|
||||
<ms-table-operator-button :tip="$t('member.edit_password')" icon="el-icon-s-tools"
|
||||
type="success" @exec="editPassword(scope.row)" v-if="!scope.row.isLdapUser"/>
|
||||
type="success" @exec="editPassword(scope.row)" v-if="scope.row.isLocalUser"/>
|
||||
</template>
|
||||
</ms-table-operator>
|
||||
</template>
|
||||
|
@ -541,7 +541,7 @@ export default {
|
|||
let roles = data.roles;
|
||||
// let userRoles = result.userRoles;
|
||||
this.$set(this.tableData[i], "roles", roles);
|
||||
this.$set(this.tableData[i], "isLdapUser", this.tableData[i].source === 'LDAP');
|
||||
this.$set(this.tableData[i], "isLocalUser", this.tableData[i].source === 'LOCAL');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue