Skip to content

Commit

Permalink
fix: 토큰 디코드시 발생하는 에러 처리 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
wjdtkdgns committed Sep 21, 2024
1 parent 2b79923 commit ae1b81b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,16 @@ class AuthFacade(
}
}

suspend fun getUidFromToken(token: AuthUserToken): Long {
return jwtTokenService.decodeToken(token).id
suspend fun getUidFromTokenOrNull(token: AuthUserToken): Long? {
return try {
jwtTokenService.decodeToken(token).id
} catch (e: Exception) {
null
}
}

suspend fun getUidFromTokenOrThrow(token: AuthUserToken): Long {
return getUidFromTokenOrNull(token) ?: throw InvalidTokenException(ErrorCode.INVALID_TOKEN)
}

private fun raiseIf(userStatus: UserStatus): UserStatusTypeModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SystemActionLogEventListener(
mdcCoroutineScope(Dispatchers.IO + Job() + coroutineExceptionHandler.handler, event.traceId).launch {
val uid = event.token
?.let { token -> AuthUserToken.from(token) }
?.let { token -> authFacade.getUidFromToken(token) }
?.let { token -> authFacade.getUidFromTokenOrNull(token) }

SystemActionLog(
uid = uid,
Expand Down

0 comments on commit ae1b81b

Please sign in to comment.