mirror of
https://github.com/ktds-dg0501/kt-event-marketing.git
synced 2026-06-12 23:19:10 +00:00
UserPricipal 충돌 부분 조치
This commit is contained in:
@@ -49,17 +49,19 @@ public class JwtTokenProvider {
|
||||
* Access Token 생성
|
||||
*
|
||||
* @param userId 사용자 ID
|
||||
* @param storeId 매장 ID
|
||||
* @param email 이메일
|
||||
* @param name 이름
|
||||
* @param roles 역할 목록
|
||||
* @return Access Token
|
||||
*/
|
||||
public String createAccessToken(Long userId, String email, String name, List<String> roles) {
|
||||
public String createAccessToken(Long userId, Long storeId, String email, String name, List<String> roles) {
|
||||
Date now = new Date();
|
||||
Date expiryDate = new Date(now.getTime() + accessTokenValidityMs);
|
||||
|
||||
return Jwts.builder()
|
||||
.subject(userId.toString())
|
||||
.claim("storeId", storeId != null ? storeId.toString() : null)
|
||||
.claim("email", email)
|
||||
.claim("name", name)
|
||||
.claim("roles", roles)
|
||||
@@ -110,12 +112,14 @@ public class JwtTokenProvider {
|
||||
Claims claims = parseToken(token);
|
||||
|
||||
Long userId = Long.parseLong(claims.getSubject());
|
||||
String storeIdStr = claims.get("storeId", String.class);
|
||||
Long storeId = storeIdStr != null ? Long.parseLong(storeIdStr) : null;
|
||||
String email = claims.get("email", String.class);
|
||||
String name = claims.get("name", String.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> roles = claims.get("roles", List.class);
|
||||
|
||||
return new UserPrincipal(userId, email, name, roles);
|
||||
return new UserPrincipal(userId, storeId, email, name, roles);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,11 @@ public class UserPrincipal implements UserDetails {
|
||||
*/
|
||||
private final Long userId;
|
||||
|
||||
/**
|
||||
* 매장 ID
|
||||
*/
|
||||
private final Long storeId;
|
||||
|
||||
/**
|
||||
* 사용자 이메일
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user