diff --git a/internal/api/v1/user/types.go b/internal/api/v1/user/types.go index 064848ef1..1b6212830 100644 --- a/internal/api/v1/user/types.go +++ b/internal/api/v1/user/types.go @@ -4,7 +4,7 @@ import v1User "github.com/KubeOperator/kubepi/internal/model/v1/user" type User struct { v1User.User - Roles []string `json:"roles"` - Password string `json:"password"` + Roles []string `json:"roles"` + OldPassword string `json:"oldPassword"` + Password string `json:"password"` } - diff --git a/internal/api/v1/user/user.go b/internal/api/v1/user/user.go index d921a71e9..3cb3bdf96 100644 --- a/internal/api/v1/user/user.go +++ b/internal/api/v1/user/user.go @@ -329,9 +329,9 @@ func (h *Handler) UpdateUser() iris.Handler { return } if req.Password != "" { - if err := h.userService.ResetPassword(userName, req.Password, common.DBOptions{}); err != nil { + if err := h.userService.UpdatePassword(userName, req.OldPassword, req.Password, common.DBOptions{}); err != nil { ctx.StatusCode(iris.StatusInternalServerError) - ctx.Values().Set("message", err.Error()) + ctx.Values().Set("message", "can not match original password") return } ctx.Values().Set("data", "ok") diff --git a/web/kubepi/src/business/app-layout/header-components/UserSetting.vue b/web/kubepi/src/business/app-layout/header-components/UserSetting.vue index b101a73ae..aa2b7bd26 100644 --- a/web/kubepi/src/business/app-layout/header-components/UserSetting.vue +++ b/web/kubepi/src/business/app-layout/header-components/UserSetting.vue @@ -9,6 +9,9 @@ {{ $t("commons.personal.profile") }} + + {{ $t("business.user.change_password") }} + @@ -27,7 +30,8 @@ export default { name: "UserSetting", computed: { ...mapGetters([ - "nickName" + "nickName", + "name" ]) }, methods: { @@ -39,6 +43,9 @@ export default { case "profile": this.$router.push("/profile") break + case "password": + this.$router.push({name: "UserPassword", params: {name: this.name}}) + break default: this.aboutDialogVisible = true break diff --git a/web/kubepi/src/business/profile/index.vue b/web/kubepi/src/business/profile/index.vue index 54f07d8f3..0ffcecb63 100644 --- a/web/kubepi/src/business/profile/index.vue +++ b/web/kubepi/src/business/profile/index.vue @@ -21,10 +21,6 @@ - - {{ $t('business.user.change_password') }} - - {{ $t("commons.button.edit") }} @@ -36,75 +32,27 @@ - - - - - - - - - - - - - - - - - - {{ $t("commons.button.cancel") }} - {{ $t("commons.button.confirm") }} - - - - + + + \ No newline at end of file diff --git a/web/kubepi/src/i18n/lang/en-US.js b/web/kubepi/src/i18n/lang/en-US.js index 090eda7f7..c1d53b781 100644 --- a/web/kubepi/src/i18n/lang/en-US.js +++ b/web/kubepi/src/i18n/lang/en-US.js @@ -42,7 +42,8 @@ const message = { search: "Search", rbac_manage: "RBAC Manage", sync: "Sync", - bind: "Bind" + bind: "Bind", + change_password: 'Change Password', }, table: { name: "Name", diff --git a/web/kubepi/src/i18n/lang/zh-CN.js b/web/kubepi/src/i18n/lang/zh-CN.js index 395387e9f..f08a5a481 100644 --- a/web/kubepi/src/i18n/lang/zh-CN.js +++ b/web/kubepi/src/i18n/lang/zh-CN.js @@ -42,7 +42,8 @@ const message = { search: "搜索", rbac_manage: "授权", sync: "同步", - bind: "绑定" + bind: "绑定", + change_password: '改密', }, table: { name: "名称", diff --git a/web/kubepi/src/router/modules/users.js b/web/kubepi/src/router/modules/users.js index 6d76c7498..a14f3d4bc 100644 --- a/web/kubepi/src/router/modules/users.js +++ b/web/kubepi/src/router/modules/users.js @@ -46,6 +46,16 @@ const UserManagement = { activeMenu: "/user-management/users", } }, + { + props: true, + path: "users/password/:name", + component: () => import("@/business/user-management/user/password"), + name: "UserPassword", + hidden: true, + meta: { + activeMenu: "/user-management/users", + } + }, { path: "roles", component: () => import("@/business/user-management/role"),