Browse Source

[Fix-7857] The user won't be allowed to disable their own account. (#7891)

3.0.0/version-upgrade
calvin 3 years ago committed by GitHub
parent
commit
24eb40c2b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java
  2. 6
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
  3. 11
      dolphinscheduler-ui/src/js/conf/home/pages/security/pages/users/_source/createUser.vue

3
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java

@ -365,7 +365,8 @@ public enum Status {
ENVIRONMENT_WORKER_GROUPS_IS_INVALID(130015, "environment worker groups is invalid format", "环境关联的工作组参数解析错误"),
UPDATE_ENVIRONMENT_WORKER_GROUP_RELATION_ERROR(130016,"You can't modify the worker group, because the worker group [{0}] and this environment [{1}] already be used in the task [{2}]",
"您不能修改工作组选项,因为该工作组 [{0}] 和 该环境 [{1}] 已经被用在任务 [{2}] 中"),
TASK_GROUP_QUEUE_ALREADY_START(130017, "task group queue already start", "节点已经获取任务组资源")
TASK_GROUP_QUEUE_ALREADY_START(130017, "task group queue already start", "节点已经获取任务组资源"),
NOT_ALLOW_TO_DISABLE_OWN_ACCOUNT(130020, "Not allow to disable your own account", "不能停用自己的账号"),
;
private final int code;

6
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java

@ -407,6 +407,12 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, phone);
return result;
}
if (state == 0 && user.getState() != state && loginUser.getId() == user.getId()) {
putMsg(result, Status.NOT_ALLOW_TO_DISABLE_OWN_ACCOUNT);
return result;
}
user.setPhone(phone);
user.setQueue(queue);
user.setState(state);

11
dolphinscheduler-ui/src/js/conf/home/pages/security/pages/users/_source/createUser.vue

@ -103,7 +103,7 @@
</el-input>
</template>
</m-list-box-f>
<m-list-box-f style="line-height: 38px;">
<m-list-box-f v-if="showState" style="line-height: 38px;">
<template slot="name">{{$t('State')}}</template>
<template slot="content">
<el-radio-group v-model="userState" size="small">
@ -123,6 +123,7 @@
import router from '@/conf/home/router'
import mPopover from '@/module/components/popup/popover'
import mListBoxF from '@/module/components/listBoxF/listBoxF'
import { mapState } from 'vuex'
export default {
name: 'create-user',
@ -139,6 +140,7 @@
phone: '',
userState: '1',
tenantList: [],
showState: true,
// Source admin user information
isADMIN: store.state.user.userInfo.userType === 'ADMIN_USER' && router.history.current.name !== 'account'
}
@ -292,6 +294,7 @@
watch: {},
created () {
// Administrator gets tenant list
this.showState = true
if (this.isADMIN) {
Promise.all([this._getQueueList(), this._getTenantList()]).then(() => {
if (this.item) {
@ -301,6 +304,7 @@
this.phone = this.item.phone
this.state = this.item.state
this.userState = this.item.state + '' || '1'
this.showState = this.item.id !== this.userInfo.id
if (this.fromUserInfo || this.item.tenantId) {
this.tenantId = this.item.tenantId
}
@ -320,6 +324,7 @@
this.phone = this.item.phone
this.state = this.item.state
this.userState = this.state + '' || '1'
this.showState = this.item.id !== this.userInfo.id
if (this.fromUserInfo || this.item.tenantId) {
this.tenantId = this.item.tenantId
}
@ -335,7 +340,9 @@
}
},
mounted () {
},
computed: {
...mapState('user', ['userInfo'])
},
components: { mPopover, mListBoxF }
}

Loading…
Cancel
Save