feat: 完成分享、单会话与发布审批改造
- 增加工作流协作分享与知识库卡片分享入口,统一低版本浏览器复制反馈 - Web 新登录替换旧会话,并保持 API Key 会话隔离 - 发布审批增加必填说明并在审批详情展示 - 账号重置与导入改用可配置默认强密码
This commit is contained in:
@@ -48,9 +48,12 @@ public class GlobalErrorResolver implements HandlerExceptionResolver {
|
||||
if (ex instanceof MissingServletRequestParameterException) {
|
||||
response.setStatus(HttpStatus.BAD_REQUEST.value());
|
||||
error = Result.fail(400, ((MissingServletRequestParameterException) ex).getParameterName() + " 不能为空");
|
||||
} else if (ex instanceof NotLoginException) {
|
||||
} else if (ex instanceof NotLoginException notLoginException) {
|
||||
response.setStatus(HttpStatus.UNAUTHORIZED.value());
|
||||
error = Result.fail(401, "请登录");
|
||||
String message = NotLoginException.BE_REPLACED.equals(notLoginException.getType())
|
||||
? "该账号已在其他设备登录,请重新登录"
|
||||
: "请登录";
|
||||
error = Result.fail(401, message);
|
||||
} else if (ex instanceof NotPermissionException || ex instanceof NotRoleException) {
|
||||
response.setStatus(HttpStatus.FORBIDDEN.value());
|
||||
error = Result.fail(403, "无权操作");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package tech.easyflow.common.web.error;
|
||||
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import org.junit.Test;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -22,6 +23,26 @@ public class GlobalErrorResolverTest {
|
||||
|
||||
private final GlobalErrorResolver resolver = new GlobalErrorResolver();
|
||||
|
||||
/**
|
||||
* 验证被新 Web 登录替换的旧会话返回明确的 401 提示。
|
||||
*/
|
||||
@Test
|
||||
public void shouldExplainReplacedLoginSession() {
|
||||
Resolution resolution = resolve(NotLoginException.newInstance(
|
||||
"login",
|
||||
NotLoginException.BE_REPLACED,
|
||||
NotLoginException.BE_REPLACED_MESSAGE,
|
||||
null
|
||||
));
|
||||
|
||||
assertEquals(401, resolution.response.getStatus());
|
||||
assertEquals(401, resolution.modelAndView.getModel().get("errorCode"));
|
||||
assertEquals(
|
||||
"该账号已在其他设备登录,请重新登录",
|
||||
resolution.modelAndView.getModel().get("message")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证业务冲突不会被包装为 HTTP 200。
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user