diff --git a/orion-ops-framework/orion-ops-framework-common/src/main/java/com/orion/ops/framework/common/constant/ErrorMessage.java b/orion-ops-framework/orion-ops-framework-common/src/main/java/com/orion/ops/framework/common/constant/ErrorMessage.java
index fa54f903..d05d2696 100644
--- a/orion-ops-framework/orion-ops-framework-common/src/main/java/com/orion/ops/framework/common/constant/ErrorMessage.java
+++ b/orion-ops-framework/orion-ops-framework-common/src/main/java/com/orion/ops/framework/common/constant/ErrorMessage.java
@@ -63,4 +63,6 @@ public interface ErrorMessage {
String PASSWORD_MISSING = "请输入密码";
+ String BEFORE_PASSWORD_ERROR = "原密码错误";
+
}
diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/controller/AuthenticationController.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/controller/AuthenticationController.java
index 7b7209e4..d80f3c81 100644
--- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/controller/AuthenticationController.java
+++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/controller/AuthenticationController.java
@@ -4,11 +4,10 @@ import com.orion.lang.define.wrapper.HttpWrapper;
import com.orion.ops.framework.biz.operator.log.core.annotation.OperatorLog;
import com.orion.ops.framework.log.core.annotation.IgnoreLog;
import com.orion.ops.framework.log.core.enums.IgnoreLogMode;
-import com.orion.ops.framework.security.core.utils.SecurityUtils;
import com.orion.ops.framework.web.core.annotation.RestWrapper;
import com.orion.ops.module.infra.define.operator.AuthenticationOperatorType;
import com.orion.ops.module.infra.entity.request.user.UserLoginRequest;
-import com.orion.ops.module.infra.entity.request.user.UserResetPasswordRequest;
+import com.orion.ops.module.infra.entity.request.user.UserUpdatePasswordRequest;
import com.orion.ops.module.infra.entity.vo.UserLoginVO;
import com.orion.ops.module.infra.service.AuthenticationService;
import com.orion.ops.module.infra.service.SystemUserService;
@@ -66,10 +65,8 @@ public class AuthenticationController {
@OperatorLog(AuthenticationOperatorType.UPDATE_PASSWORD)
@Operation(summary = "修改密码")
@PutMapping("/update-password")
- public HttpWrapper> updatePassword(@Validated @RequestBody UserResetPasswordRequest request) {
- // 当前用户id
- request.setId(SecurityUtils.getLoginUserId());
- systemUserService.resetPassword(request);
+ public HttpWrapper> updatePassword(@Validated @RequestBody UserUpdatePasswordRequest request) {
+ authenticationService.updatePassword(request);
return HttpWrapper.ok();
}
diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/user/UserResetPasswordRequest.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/user/UserResetPasswordRequest.java
index 4d06f699..2506c04b 100644
--- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/user/UserResetPasswordRequest.java
+++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/user/UserResetPasswordRequest.java
@@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
/**
* 重置密码请求
@@ -16,6 +17,7 @@ import javax.validation.constraints.NotEmpty;
@Schema(name = "UserResetPasswordRequest", description = "重置密码请求")
public class UserResetPasswordRequest {
+ @NotNull
@Schema(description = "id")
private Long id;
diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/user/UserUpdatePasswordRequest.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/user/UserUpdatePasswordRequest.java
new file mode 100644
index 00000000..ab3c3b16
--- /dev/null
+++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/user/UserUpdatePasswordRequest.java
@@ -0,0 +1,27 @@
+package com.orion.ops.module.infra.entity.request.user;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+
+/**
+ * 修改密码请求
+ *
+ * @author Jiahang Li
+ * @version 1.0.0
+ * @since 2023/7/17 12:19
+ */
+@Data
+@Schema(name = "UserUpdatePasswordRequest", description = "修改密码请求")
+public class UserUpdatePasswordRequest {
+
+ @NotEmpty
+ @Schema(description = "原密码")
+ private String beforePassword;
+
+ @NotEmpty
+ @Schema(description = "新密码")
+ private String password;
+
+}
diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/AuthenticationService.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/AuthenticationService.java
index 72ce1567..4cda1c2a 100644
--- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/AuthenticationService.java
+++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/AuthenticationService.java
@@ -3,6 +3,7 @@ package com.orion.ops.module.infra.service;
import com.orion.ops.framework.common.security.LoginUser;
import com.orion.ops.module.infra.entity.dto.LoginTokenDTO;
import com.orion.ops.module.infra.entity.request.user.UserLoginRequest;
+import com.orion.ops.module.infra.entity.request.user.UserUpdatePasswordRequest;
import com.orion.ops.module.infra.entity.vo.UserLoginVO;
import javax.servlet.http.HttpServletRequest;
@@ -42,6 +43,13 @@ public interface AuthenticationService {
*/
void logout(HttpServletRequest servletRequest);
+ /**
+ * 修改密码
+ *
+ * @param request request
+ */
+ void updatePassword(UserUpdatePasswordRequest request);
+
/**
* 获取登陆用户信息
*
diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/SystemUserService.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/SystemUserService.java
index df2839a0..7ad0e6f7 100644
--- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/SystemUserService.java
+++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/SystemUserService.java
@@ -73,7 +73,7 @@ public interface SystemUserService {
/**
* 删除 id 删除用户拓展信息
*
- * @param id
+ * @param id id
*/
void deleteSystemUserRel(Long id);
diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/AuthenticationServiceImpl.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/AuthenticationServiceImpl.java
index 8b2e1ef5..b2bb1b4d 100644
--- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/AuthenticationServiceImpl.java
+++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/AuthenticationServiceImpl.java
@@ -24,11 +24,14 @@ import com.orion.ops.module.infra.entity.domain.SystemRoleDO;
import com.orion.ops.module.infra.entity.domain.SystemUserDO;
import com.orion.ops.module.infra.entity.dto.LoginTokenDTO;
import com.orion.ops.module.infra.entity.request.user.UserLoginRequest;
+import com.orion.ops.module.infra.entity.request.user.UserResetPasswordRequest;
+import com.orion.ops.module.infra.entity.request.user.UserUpdatePasswordRequest;
import com.orion.ops.module.infra.entity.vo.UserLoginVO;
import com.orion.ops.module.infra.enums.LoginTokenStatusEnum;
import com.orion.ops.module.infra.enums.UserStatusEnum;
import com.orion.ops.module.infra.service.AuthenticationService;
import com.orion.ops.module.infra.service.PermissionService;
+import com.orion.ops.module.infra.service.SystemUserService;
import com.orion.web.servlet.web.Servlets;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
@@ -57,6 +60,9 @@ public class AuthenticationServiceImpl implements AuthenticationService {
@Resource
private SystemUserRoleDAO systemUserRoleDAO;
+ @Resource
+ private SystemUserService systemUserService;
+
@Resource
private PermissionService permissionService;
@@ -120,6 +126,22 @@ public class AuthenticationServiceImpl implements AuthenticationService {
redisTemplate.delete(Lists.of(loginKey, refreshKey));
}
+ @Override
+ public void updatePassword(UserUpdatePasswordRequest request) {
+ Long userId = SecurityUtils.getLoginUserId();
+ // 查询用户信息
+ SystemUserDO record = systemUserDAO.selectById(userId);
+ Valid.notNull(record, ErrorMessage.USER_ABSENT);
+ // 对比原始密码
+ String beforePassword = Signatures.md5(request.getBeforePassword());
+ Valid.eq(beforePassword, record.getPassword(), ErrorMessage.BEFORE_PASSWORD_ERROR);
+ // 重置密码
+ UserResetPasswordRequest reset = new UserResetPasswordRequest();
+ reset.setId(userId);
+ reset.setPassword(request.getPassword());
+ systemUserService.resetPassword(reset);
+ }
+
@Override
public LoginUser getLoginUser(Long id) {
String userInfoKey = UserCacheKeyDefine.USER_INFO.format(id);
diff --git a/orion-ops-ui/src/api/user/auth.ts b/orion-ops-ui/src/api/user/auth.ts
index cac0cad9..fc11ea08 100644
--- a/orion-ops-ui/src/api/user/auth.ts
+++ b/orion-ops-ui/src/api/user/auth.ts
@@ -15,6 +15,14 @@ export interface LoginResponse {
token: string;
}
+/**
+ * 修改密码请求
+ */
+export interface UserUpdatePasswordRequest {
+ beforePassword?: string;
+ password?: string;
+}
+
/**
* 登陆
*/
@@ -29,6 +37,13 @@ export function logout() {
return axios.get('/infra/auth/logout');
}
+/**
+ * 修改密码
+ */
+export function updatePassword(request: UserUpdatePasswordRequest) {
+ return axios.put('/infra/auth/update-password', request);
+}
+
/**
* 获取用户信息
*/
diff --git a/orion-ops-ui/src/components/app/navbar/index.vue b/orion-ops-ui/src/components/app/navbar/index.vue
index c76fe7ff..6ec6b394 100644
--- a/orion-ops-ui/src/components/app/navbar/index.vue
+++ b/orion-ops-ui/src/components/app/navbar/index.vue
@@ -38,15 +38,15 @@
+ shape="circle"
+ @click="setLocalesVisible">
-
+
@@ -82,7 +82,7 @@
@@ -93,7 +93,7 @@
:arrow-style="{ display: 'none' }"
:content-style="{ padding: 0, minWidth: '400px' }"
content-class="message-popover">
-
+
@@ -161,7 +161,7 @@
-
+ updatePasswordRef.open()">
修改密码
@@ -177,6 +177,8 @@
+
+
@@ -192,25 +194,14 @@
import MessageBox from '@/components/system/message-box/index.vue';
import { openAppSettingKey, toggleDrawerMenuKey } from '@/types/symbol';
import { preferenceTipsKey } from './const';
+ import UpdatePasswordModal from '@/components/user/role/update-password-modal.vue';
const tipsStore = useTipsStore();
- const tippedPreference = ref(tipsStore.isNotTipped(preferenceTipsKey));
const appStore = useAppStore();
const userStore = useUserStore();
const { logout } = useUser();
const { changeLocale, currentLocale } = useLocale();
const { isFullscreen, toggle: toggleFullScreen } = useFullscreen();
- const locales = [...LOCALE_OPTIONS];
- const nickname = computed(() => {
- return userStore.nickname?.substring(0, 1);
- });
- const topMenu = computed(() => appStore.topMenu && appStore.menu);
-
- // 当前主题
- const theme = computed(() => {
- return appStore.theme;
- });
-
// 主题
const darkTheme = useDark({
selector: 'body',
@@ -225,24 +216,42 @@
},
});
+ // 用户名
+ const nickname = computed(() => userStore.nickname?.substring(0, 1));
+ // 是否展示顶部菜单
+ const topMenu = computed(() => appStore.topMenu && appStore.menu);
+ // 当前主题
+ const theme = computed(() => appStore.theme);
+
+ const locales = [...LOCALE_OPTIONS];
+ // 偏好提示
+ const tippedPreference = ref(tipsStore.isNotTipped(preferenceTipsKey));
+ // 修改密码
+ const updatePasswordRef = ref();
+ // 消息
+ const messageRef = ref();
+ // 语言
+ const localeRef = ref();
+
+ // 打开应用设置
+ const openAppSetting = inject(openAppSettingKey) as () => void;
+
+ // 注入收缩菜单
+ const toggleDrawerMenu = inject(toggleDrawerMenuKey) as () => void;
+
// 切换主题
const handleToggleTheme = () => {
useToggle(darkTheme)();
};
- // 打开应用设置
- const openAppSetting = inject(openAppSettingKey) as () => void;
-
- // 消息触发器 ref
- const refMessageBoxTrigger = ref();
+ // 打开消息
const setMessageBoxVisible = () => {
- triggerMouseEvent(refMessageBoxTrigger);
+ triggerMouseEvent(messageRef);
};
- // 个人信息触发器 ref
- const refUserInfoTrigger = ref();
- const setUserInfoVisible = () => {
- triggerMouseEvent(refUserInfoTrigger);
+ // 打开语言切换
+ const setLocalesVisible = () => {
+ triggerMouseEvent(localeRef);
};
// 退出登录
@@ -250,9 +259,6 @@
logout();
};
- // 注入收缩菜单
- const toggleDrawerMenu = inject(toggleDrawerMenuKey) as () => void;
-
// 关闭偏好提示
const closePreferenceTip = (ack: boolean) => {
tippedPreference.value = false;
diff --git a/orion-ops-ui/src/components/meta/history/history-value-modal.vue b/orion-ops-ui/src/components/meta/history/history-value-modal.vue
index 06e62090..5c34c7f9 100644
--- a/orion-ops-ui/src/components/meta/history/history-value-modal.vue
+++ b/orion-ops-ui/src/components/meta/history/history-value-modal.vue
@@ -80,10 +80,11 @@
+
+
+
+