feat:jwt续期实现

This commit is contained in:
haoxr 2020-11-20 20:26:14 +08:00
parent ff4ef4285b
commit f163298472
2 changed files with 1 additions and 26 deletions

View File

@ -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());
}
}

View File

@ -94,7 +94,7 @@ public class ResourceServerConfig {
return (exchange, e) -> {
Mono<Void> 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");