✨ Introducing new features. closed #3013 【重构】重构前端index.vue 的刷新逻辑抽取成对应的方法

This commit is contained in:
wjie committed 2021-08-05 20:20:58 +08:00
1 parent 6da9c2bbbc
commit 3ffb08968a
3 files changed
+14 -4

No files matched your search

@@ -17,7 +17,6 @@
package com.pig4cloud.pigx.common.security.component;
import cn.hutool.http.HttpStatus;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
import com.pig4cloud.pigx.common.core.util.R;
@@ -25,12 +24,14 @@ import com.pig4cloud.pigx.common.security.util.PigxSecurityMessageSourceUtil;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.CredentialsExpiredException;
import org.springframework.security.authentication.InsufficientAuthenticationException;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;
@@ -39,7 +40,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
/**
* 异常处理 {@link org.springframework.security.core.AuthenticationException } 不同细化异常处理
* 针对资源服务器的异常处理 {@link OAuth2AuthenticationProcessingFilter}不同细化异常处理
*
* @author lengleng
* @date 2020-06-14
@@ -60,6 +61,7 @@ public class PigxCommenceAuthExceptionEntryPoint implements AuthenticationEntryP
R<String> result = new R<>();
result.setMsg(authException.getMessage());
result.setData(authException.getMessage());
response.setStatus(HttpStatus.UNAUTHORIZED.value());
result.setCode(CommonConstants.FAIL);
if (authException instanceof CredentialsExpiredException
@@ -81,7 +83,13 @@ public class PigxCommenceAuthExceptionEntryPoint implements AuthenticationEntryP
result.setMsg(msg);
}
response.setStatus(HttpStatus.HTTP_UNAUTHORIZED);
if (authException instanceof InsufficientAuthenticationException) {
String msg = PigxSecurityMessageSourceUtil.getAccessor()
.getMessage("AbstractAccessDecisionManager.expireToken", authException.getMessage());
response.setStatus(HttpStatus.FAILED_DEPENDENCY.value());
result.setMsg(msg);
}
PrintWriter printWriter = response.getWriter();
printWriter.append(objectMapper.writeValueAsString(result));
}
@@ -19,6 +19,7 @@ package com.pig4cloud.pigx.common.security.exception;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.pig4cloud.pigx.common.security.component.PigxAuth2ExceptionSerializer;
import org.springframework.http.HttpStatus;
/**
* @author lengleng
@@ -40,7 +41,7 @@ public class TokenInvalidException extends PigxAuth2Exception {
@Override
public int getHttpErrorCode() {
return 427;
return HttpStatus.FAILED_DEPENDENCY.value();
}
}
@@ -17,6 +17,7 @@
# PIGX \u4E2D\u7684\u5F02\u5E38\u4FE1\u606F\u4F7F\u7528\u6B64\u6587\u4EF6\u5B9A\u4E49
#
AbstractAccessDecisionManager.accessDenied=\u6743\u9650\u4E0D\u8DB3,\u4E0D\u5141\u8BB8\u8BBF\u95EE{0}
AbstractAccessDecisionManager.expireToken=token \u8FC7\u671F
AbstractLdapAuthenticationProvider.emptyPassword=\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A
AbstractSecurityInterceptor.authenticationNotFound=\u672A\u5728SecurityContext\u4E2D\u67E5\u627E\u5230\u8BA4\u8BC1\u5BF9\u8C61
AbstractUserDetailsAuthenticationProvider.badCredentials=\u7528\u6237\u540D\u4E0D\u5B58\u5728\u6216\u8005\u5BC6\u7801\u9519\u8BEF