Skip to content

[FIX] 변경된 CustomUserPrincipal에 맞게 테스트 토큰 발급 로직 수정 #184

@Baguette-bbang

Description

@Baguette-bbang

1. Issue : 🐞 Fix / Bug

/api/v1/system/test-token 엔드포인트에서 ClassCastException 발생
String을 CustomUserPrincipal로 캐스팅하려다 실패

java.lang.ClassCastException: class java.lang.String cannot be cast to class com.divary.global.config.security.CustomUserPrincipal
at com.divary.global.config.jwt.JwtTokenProvider.generateAccessToken(JwtTokenProvider.java:45)
at com.divary.domain.system.controller.SystemController.generateTestToken(SystemController.java:118)

2. 원인 파악

UsernamePasswordAuthenticationToken의 principal을 String(email)로 설정
JwtTokenProvider.generateAccessToken()은 CustomUserPrincipal을 기대
타입 불일치로 캐스팅 실패

3. 해결 방안

이메일로 Member 조회하고
CustomUserPrincipal 생성해서
Authentication에 CustomUserPrincipal을 principal로 설정하기

Metadata

Metadata

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions