feat(ai-character): 관리자 API Phase 1 기반을 추가한다
This commit is contained in:
@@ -83,15 +83,21 @@ class TokenProvider(
|
||||
.parseClaimsJws(token)
|
||||
.body
|
||||
|
||||
val authorities = claims[AUTHORITIES_KEY].toString().split(",").map { SimpleGrantedAuthority(it) }
|
||||
val memberToken = tokenRepository.findByIdOrNull(id = claims.subject.toLong())
|
||||
val memberId = claims.subject?.toLongOrNull()
|
||||
?: throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
val authorityNames = (claims[AUTHORITIES_KEY] as? String)
|
||||
?.split(",")
|
||||
?.takeIf { names -> names.all { it.isNotBlank() } }
|
||||
?: throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
val authorities = authorityNames.map { SimpleGrantedAuthority(it) }
|
||||
val memberToken = tokenRepository.findByIdOrNull(id = memberId)
|
||||
?: throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
if (!memberToken.tokenSet.contains(token)) {
|
||||
throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
}
|
||||
|
||||
val member = repository.findByIdOrNull(id = claims.subject.toLong())
|
||||
val member = repository.findByIdOrNull(id = memberId)
|
||||
?: throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
val principal = MemberAdapter(member)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user