Skip to content

Commit

Permalink
[Fix] 로그인 오류
Browse files Browse the repository at this point in the history
  • Loading branch information
nahyeon99 committed Aug 17, 2023
1 parent 5c00bfc commit cde7e60
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/main/java/idorm/idormServer/auth/JwtTokenProvider.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package idorm.idormServer.auth;

import idorm.idormServer.exception.CustomException;
import idorm.idormServer.exception.ExceptionCode;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jws;
import io.jsonwebtoken.Jwts;
Expand Down Expand Up @@ -50,11 +52,15 @@ public Authentication getAuthentication(String token) {
}

public String getUsername(String token) {
return Jwts.parser()
.setSigningKey(JWT_SECRET_KEY)
.parseClaimsJws(token)
.getBody()
.getSubject();
try {
return Jwts.parser()
.setSigningKey(JWT_SECRET_KEY)
.parseClaimsJws(token)
.getBody()
.getSubject();
} catch (IllegalArgumentException e) {
throw new CustomException(null, ExceptionCode.UNAUTHORIZED_MEMBER);
}
}

public String resolveToken(HttpServletRequest servletRequest) {
Expand Down

0 comments on commit cde7e60

Please sign in to comment.