diff --git a/src/views/assets/AdminUser/AdminUserCreateUpdate.vue b/src/views/assets/AdminUser/AdminUserCreateUpdate.vue index 383667d4c..daa2b6f46 100644 --- a/src/views/assets/AdminUser/AdminUserCreateUpdate.vue +++ b/src/views/assets/AdminUser/AdminUserCreateUpdate.vue @@ -17,7 +17,8 @@ export default { }, fields: [ - [this.$t('common.Basic'), ['name', 'username', 'password', 'private_key', 'comment']] + [this.$t('common.Basic'), ['name', 'username', 'update_password', 'password', 'private_key']], + [this.$t('common.Other'), ['comment']] ], fieldsMeta: { name: { @@ -30,8 +31,24 @@ export default { placeholder: this.$t('common.Username') } }, + update_password: { + label: this.$t('users.UpdatePassword'), + type: 'checkbox', + hidden: (formValue) => { + if (formValue.update_password) { + return true + } + return !this.$route.params.id + } + }, password: { - helpText: this.$t('common.passwordOrPassphrase') + helpText: this.$t('common.passwordOrPassphrase'), + hidden: (formValue) => { + if (!this.$route.params.id) { + return false + } + return !formValue.update_password + } }, private_key: { component: Uploadkey diff --git a/src/views/assets/SystemUser/SystemUserCreateUpdate.vue b/src/views/assets/SystemUser/SystemUserCreateUpdate.vue index 3145ddf6c..1bf7ed6bf 100644 --- a/src/views/assets/SystemUser/SystemUserCreateUpdate.vue +++ b/src/views/assets/SystemUser/SystemUserCreateUpdate.vue @@ -30,7 +30,7 @@ export default { fields: [ [this.$t('common.Basic'), ['name', 'login_mode', 'username', 'username_same_with_user', 'priority', 'protocol']], [this.$t('assets.AutoPush'), ['auto_push', 'sudo', 'shell', 'home', 'system_groups']], - [this.$t('common.Auth'), ['auto_generate_key', 'password', 'private_key', 'token']], + [this.$t('common.Auth'), ['auto_generate_key', 'update_password', 'password', 'private_key', 'token']], [this.$t('common.Command filter'), ['cmd_filters']], [this.$t('common.Other'), ['sftp_root', 'comment']] ], @@ -175,16 +175,26 @@ export default { helpText: this.$t('assets.SudoHelpMessage'), hidden: (item) => item.protocol !== 'ssh' || !item.auto_push }, + update_password: { + label: this.$t('users.UpdatePassword'), + type: 'checkbox', + hidden: (formValue) => { + if (formValue.update_password) { + return true + } + return !this.$route.params.id + } + }, password: { helpText: this.$t('assets.PasswordHelpMessage'), hidden: form => { - if (form.login_mode !== 'auto') { + if (form.login_mode !== 'auto' || form.protocol === 'k8s' || form.auto_generate_key) { return true } - if (form.protocol === 'k8s') { - return true + if (!this.$route.params.id) { + return false } - return form.auto_generate_key === true + return !form.update_password } }, shell: {