Skip to content

Commit

Permalink
fix: temporary change to auth logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mushroom1324 committed Sep 25, 2024
1 parent 797c52d commit be39a8d
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/main/java/com/example/repick/global/jwt/TokenService.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ protected void init() {

// access ํ† ํฐ ์ƒ์„ฑ
public String createAccessToken(UserDetailsImpl userDetailsImpl) {
return createToken(userDetailsImpl.user().getProviderId(), userDetailsImpl.user().getRole(), 8640000000L);
return createToken(userDetailsImpl.user().getProviderId(), userDetailsImpl.user().getRole(), 86400000000L);
}

// refresh ํ† ํฐ ์ƒ์„ฑ
public String createRefreshToken(UserDetailsImpl userDetailsImpl) {
return createToken(userDetailsImpl.user().getProviderId(), userDetailsImpl.user().getRole(), 8640000000L);
return createToken(userDetailsImpl.user().getProviderId(), userDetailsImpl.user().getRole(), 86400000000L);
}

// ํ† ํฐ ์ƒ์„ฑ
Expand All @@ -65,7 +65,21 @@ public Authentication getAuthentication(String token) {

// ํ† ํฐ์— ๋‹ด๊ฒจ์žˆ๋Š” ์œ ์ € userId ํš๋“
public String getProviderId(String token) {
return Jwts.parserBuilder().setSigningKey(secretKey).build().parseClaimsJws(token).getBody().getSubject();
// return Jwts.parserBuilder().setSigningKey(secretKey).build().parseClaimsJws(token).getBody().getSubject();
try {
// ์ •์ƒ์ ์ธ ๊ฒฝ์šฐ ํ† ํฐ์—์„œ subject(providerId)๋ฅผ ์ถ”์ถœ
return Jwts.parserBuilder()
.setSigningKey(secretKey)
.build()
.parseClaimsJws(token)
.getBody()
.getSubject();

} catch (ExpiredJwtException e) {
// ๋งŒ๋ฃŒ๋œ ํ† ํฐ์˜ Claims์—์„œ subject(providerId)๋ฅผ ์ถ”์ถœ
Claims claims = e.getClaims();
return claims.getSubject();
}
}

/* ์ถ”๊ฐ€๋จ: getMember
Expand Down

0 comments on commit be39a8d

Please sign in to comment.