perf: 禁止用户自身更新自己的某些属性

This commit is contained in:
wangruidong 2024-02-01 18:00:44 +08:00 committed by Bryan
parent 2a92c7657c
commit ba109da324
5 changed files with 24 additions and 9 deletions

View File

@ -7,13 +7,11 @@
v-bind="data.attrs"
>
<template v-if="data.helpTips" #label>
{{ data.label }}
<el-tooltip placement="top" effect="light" popper-class="help-tips">
<div slot="content" v-html="data.helpTips" />
<el-button style="padding: 0">
<i class="fa fa-question-circle" />
</el-button>
<i class="fa fa-question-circle-o" />
</el-tooltip>
{{ data.label }}
</template>
<template v-if="readonly && hasReadonlyContent">
<div
@ -70,7 +68,8 @@
:key="opt.label"
v-bind="opt"
:label="'value' in opt ? opt.value : opt.label"
>{{ opt.label }}</el-radio>
>{{ opt.label }}
</el-radio>
</template>
</custom-component>
<div v-if="data.helpText" class="help-block" v-html="data.helpText" />

View File

@ -2116,7 +2116,8 @@
"passwordWillExpiredPrefixMsg": "The password will expire in ",
"passwordWillExpiredSuffixMsg": " days.Please change your password as soon as possible.",
"dateLastLogin": "Date last login",
"AddAllMembersWarningMsg": "Are you sure you want to add all members?"
"AddAllMembersWarningMsg": "Are you sure you want to add all members?",
"disallowSelfUpdateFields": "Not allowed to modify the current fields oneself"
},
"notifications": {
"MessageType": "Message Type",

View File

@ -2105,7 +2105,8 @@
"passwordExpired": "パスワードが期限切れです",
"passwordWillExpiredPrefixMsg": "パスワードはまもなく",
"passwordWillExpiredSuffixMsg": "期限が切れた後、できるだけ早くパスワードを変更してください。",
"AddAllMembersWarningMsg": "すべてのメンバーを追加してもよろしいですか?"
"AddAllMembersWarningMsg": "すべてのメンバーを追加してもよろしいですか?",
"disallowSelfUpdateFields": "現在のフィールドを自分で変更することは許可されていません"
},
"notifications": {
"MessageType": "メッセージタイプ",

View File

@ -2099,7 +2099,8 @@
"SetPublicKey": "设置SSH公钥",
"passwordExpired": "密码过期了",
"passwordWillExpiredPrefixMsg": "密码即将在 ",
"passwordWillExpiredSuffixMsg": "天 后过期,请尽快修改您的密码。"
"passwordWillExpiredSuffixMsg": "天 后过期,请尽快修改您的密码。",
"disallowSelfUpdateFields": "不允许自己修改当前字段"
},
"notifications": {
"MessageType": "消息类型",

View File

@ -133,6 +133,7 @@ export default {
},
org_roles: {
component: Select2,
label: this.$t('users.OrgRoles'),
rules: this.$store.getters.currentOrgIsRoot ? [] : [rules.RequiredChange],
el: {
multiple: true,
@ -164,6 +165,10 @@ export default {
},
phone: {
component: PhoneInput
},
is_active: {
label: this.$t('users.IsActive'),
el: {}
}
},
submitMethod() {
@ -200,7 +205,7 @@ export default {
}
},
computed: {
...mapGetters(['currentOrgIsRoot'])
...mapGetters(['currentOrgIsRoot', 'currentUser'])
},
async mounted() {
if (this.currentOrgIsRoot) {
@ -212,6 +217,14 @@ export default {
methods: {
afterGetUser(user) {
this.user = user
if (this.user.id === this.currentUser.id) {
const fieldsToUpdate = ['system_roles', 'org_roles', 'is_active']
fieldsToUpdate.forEach(field => {
const msg = this.$t('users.disallowSelfUpdateFields', { attr: this.fieldsMeta[field]['label'] })
this.fieldsMeta[field].el.disabled = true
this.fieldsMeta[field].helpTips = msg
})
}
this.fieldsMeta.password.el.userIsOrgAdmin = user['is_org_admin']
if (this.$route.query.clone_from) {
this.user.groups = []