mirror of
https://github.com/ktds-dg0501/kt-event-marketing.git
synced 2026-06-13 01:49:10 +00:00
백엔드 서비스 구조 개선 및 데이터베이스 스키마 추가
This commit is contained in:
@@ -12,7 +12,6 @@ import javax.crypto.SecretKey;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* JWT 토큰 생성 및 검증 제공자
|
||||
@@ -57,13 +56,13 @@ public class JwtTokenProvider {
|
||||
* @return Access Token
|
||||
*/
|
||||
|
||||
public String createAccessToken(UUID userId, UUID storeId, String email, String name, List<String> roles) {
|
||||
public String createAccessToken(String userId, String 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)
|
||||
.subject(userId)
|
||||
.claim("storeId", storeId)
|
||||
.claim("email", email)
|
||||
.claim("name", name)
|
||||
.claim("roles", roles)
|
||||
@@ -80,12 +79,12 @@ public class JwtTokenProvider {
|
||||
* @param userId 사용자 ID
|
||||
* @return Refresh Token
|
||||
*/
|
||||
public String createRefreshToken(UUID userId) {
|
||||
public String createRefreshToken(String userId) {
|
||||
Date now = new Date();
|
||||
Date expiryDate = new Date(now.getTime() + refreshTokenValidityMs);
|
||||
|
||||
return Jwts.builder()
|
||||
.subject(userId.toString())
|
||||
.subject(userId)
|
||||
.claim("type", "refresh")
|
||||
.issuedAt(now)
|
||||
.expiration(expiryDate)
|
||||
@@ -99,9 +98,9 @@ public class JwtTokenProvider {
|
||||
* @param token JWT 토큰
|
||||
* @return 사용자 ID
|
||||
*/
|
||||
public UUID getUserIdFromToken(String token) {
|
||||
public String getUserIdFromToken(String token) {
|
||||
Claims claims = parseToken(token);
|
||||
return UUID.fromString(claims.getSubject());
|
||||
return claims.getSubject();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,9 +112,8 @@ public class JwtTokenProvider {
|
||||
public UserPrincipal getUserPrincipalFromToken(String token) {
|
||||
Claims claims = parseToken(token);
|
||||
|
||||
UUID userId = UUID.fromString(claims.getSubject());
|
||||
String storeIdStr = claims.get("storeId", String.class);
|
||||
UUID storeId = storeIdStr != null ? UUID.fromString(storeIdStr) : null;
|
||||
String userId = claims.getSubject();
|
||||
String storeId = claims.get("storeId", String.class);
|
||||
String email = claims.get("email", String.class);
|
||||
String name = claims.get("name", String.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -24,12 +23,12 @@ public class UserPrincipal implements UserDetails {
|
||||
/**
|
||||
* 사용자 ID
|
||||
*/
|
||||
private final UUID userId;
|
||||
private final String userId;
|
||||
|
||||
/**
|
||||
* 매장 ID
|
||||
*/
|
||||
private final UUID storeId;
|
||||
private final String storeId;
|
||||
|
||||
/**
|
||||
* 사용자 이메일
|
||||
|
||||
Reference in New Issue
Block a user