diff --git a/youlai-auth/src/main/java/com/youlai/auth/exception/AuthExceptionHandler.java b/youlai-auth/src/main/java/com/youlai/auth/exception/AuthExceptionHandler.java index 43271b008..3656649dd 100644 --- a/youlai-auth/src/main/java/com/youlai/auth/exception/AuthExceptionHandler.java +++ b/youlai-auth/src/main/java/com/youlai/auth/exception/AuthExceptionHandler.java @@ -1,12 +1,9 @@ package com.youlai.auth.exception; import com.youlai.common.core.result.Result; -import com.youlai.common.core.result.ResultCode; import lombok.extern.slf4j.Slf4j; import org.springframework.security.authentication.InternalAuthenticationServiceException; -import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.security.oauth2.common.exceptions.InvalidGrantException; -import org.springframework.security.oauth2.common.exceptions.InvalidTokenException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; @@ -14,18 +11,6 @@ import org.springframework.web.bind.annotation.RestControllerAdvice; @Slf4j public class AuthExceptionHandler { - - /** - * 客户端信息错误 - * - * @param e - * @return - */ - @ExceptionHandler(UsernameNotFoundException.class) - public Result handleUsernameNotFoundException(UsernameNotFoundException e) { - return Result.error(e.getMessage()); - } - /** * 用户名和密码异常 * @@ -49,14 +34,4 @@ public class AuthExceptionHandler { return Result.error(e.getMessage()); } - - @ExceptionHandler(InvalidTokenException.class) - public Result handleInvalidTokenException(InvalidTokenException e) { - return Result.custom(ResultCode.TOKEN_INVALID_OR_EXPIRED); - } - - @ExceptionHandler(Exception.class) - public Result handleException(Exception e) { - return Result.error(e.getMessage()); - } } diff --git a/youlai-gateway/src/main/java/com/youlai/gateway/config/ResourceServerConfig.java b/youlai-gateway/src/main/java/com/youlai/gateway/config/ResourceServerConfig.java index f6cb18dda..cabecd88f 100644 --- a/youlai-gateway/src/main/java/com/youlai/gateway/config/ResourceServerConfig.java +++ b/youlai-gateway/src/main/java/com/youlai/gateway/config/ResourceServerConfig.java @@ -94,7 +94,7 @@ public class ResourceServerConfig { return (exchange, e) -> { Mono mono = Mono.defer(() -> Mono.just(exchange.getResponse())) .flatMap(response -> { - response.setStatusCode(HttpStatus.UNAUTHORIZED); + response.setStatusCode(HttpStatus.OK); response.getHeaders().set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); response.getHeaders().set("Access-Control-Allow-Origin", "*"); response.getHeaders().set("Cache-Control", "no-cache");