Skip to content

Commit

Permalink
fix: Method getNewAccessToken does not work properly
Browse files Browse the repository at this point in the history
  • Loading branch information
arturhasparian committed Jan 15, 2024
1 parent d2a8b53 commit 90e41e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ public void saveJwtRefreshToken(String email, String jwtRefreshToken) {
refreshStorage.put(email, jwtRefreshToken);
}

public JwtResponse getJwtAccessToken(@NotNull String refreshToken) {
Authentication authentication = authenticateWithRefreshToken(refreshToken);
String accessToken = jwtUtils.generateJwtToken(authentication);
return new JwtResponse(accessToken, refreshToken);
public JwtResponse getJwtAccessToken(@NotNull String refreshToken) throws AuthException {
if (jwtUtils.validateRefreshToken(refreshToken)) {
Authentication authentication = authenticateWithRefreshToken(refreshToken);
String accessToken = jwtUtils.generateJwtToken(authentication);
return new JwtResponse(accessToken, null);
}
throw new AuthException("Invalid token");
}

public JwtResponse getJwtRefreshToken(@NotNull String refreshToken) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.requestMatchers(
HttpMethod.POST,
"/advertisement",
"/auth/refresh/**",
"/image"
)
.authenticated()
Expand Down

0 comments on commit 90e41e2

Please sign in to comment.