Skip to content

Commit

Permalink
๐Ÿ› CORS ์˜ค๋ฅ˜ ์ˆ˜์ •
Browse files Browse the repository at this point in the history
- ์„œ๋น„์Šค ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ•˜์˜€์Šต๋‹ˆ๋‹ค.
  • Loading branch information
Ganghee-Lee-0522 committed Jan 12, 2024
1 parent 037e905 commit f98c8ca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public String createAccessToken(Member member) {
Claims claims = Jwts.claims();
claims.put("nickname", member.getNickname());
claims.put("memberId", member.getId());
claims.put("role", member.getRole());
claims.put("role", member.getRole().getRole());
long validTime = accessTokenTime;
Date now = new Date();
return Jwts.builder()
Expand Down Expand Up @@ -110,17 +110,25 @@ public Long getExpiration(String token) {
}

public String getNicknameFromToken(String token) {
return (String) getClaims(token).get("nickname");
return String.valueOf(getClaims(token).get("nickname"));
}

public Long getMemberIdFromToken(String token) {
return Long.valueOf(getClaims(token).get("memberId").toString());
}

public Role getRoleFromToken(String token) {
return Role.valueOf(getClaims(token).get("role").toString());
return Role.ROLE_MEMBER;
// return Role.valueOf(getClaims(token).get("role").toString());
}

// public Role getRoleFromToken(String token) {
// Object roleValue = getClaims(token).get("role");
// return roleValue != null ? Role.valueOf(roleValue.toString()) : null;
// }



public Claims getClaims(String token) {
return Jwts.parser().setSigningKey(jwtSecretKey).parseClaimsJws(token).getBody();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public enum Role { // ์œ ์ € ๊ถŒํ•œ(๊ฒŒ์ŠคํŠธ/๋ฉค๋ฒ„)
private final String title;

public static Role getDefaultRole() {
return ROLE_GUEST; // ๊ธฐ๋ณธ๊ฐ’์€ ROLE_GUEST๋กœ ์„ค์ •
return ROLE_MEMBER; // ๊ธฐ๋ณธ๊ฐ’์€ ROLE_GUEST๋กœ ์„ค์ •
}
}

0 comments on commit f98c8ca

Please sign in to comment.