Skip to content

Commit

Permalink
refactor: 잘못된 token에 대한 에러 핸들링
Browse files Browse the repository at this point in the history
  • Loading branch information
bperhaps committed Oct 19, 2021
1 parent 690d44e commit 1695967
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.springframework.web.util.ContentCachingRequestWrapper;
import wooteco.prolog.login.application.AuthorizationExtractor;
import wooteco.prolog.login.application.JwtTokenProvider;
import wooteco.prolog.login.excetpion.TokenNotValidException;

@Component
public class SlackMessageGenerator {
Expand Down Expand Up @@ -61,7 +62,11 @@ private String getCurrentTime() {
}

private String getUserId(String token) {
return token == null ? "Guest" : jwtTokenProvider.extractSubject(token);
try {
return jwtTokenProvider.extractSubject(token);
} catch (TokenNotValidException e) {
return "Guest";
}
}

private String extractHeaders(ContentCachingRequestWrapper request) {
Expand Down

0 comments on commit 1695967

Please sign in to comment.