generated from pricelees/issue-pr-template
[#44] 매장 기능 도입 #45
@ -18,8 +18,9 @@ import roomescape.user.business.UserService
|
||||
|
||||
private val log: KLogger = KotlinLogging.logger {}
|
||||
|
||||
const val CLAIM_ADMIN_TYPE_KEY = "admin_type"
|
||||
const val CLAIM_PERMISSION_KEY = "permission"
|
||||
const val CLAIM_TYPE_KEY = "principal_type"
|
||||
const val CLAIM_STORE_ID_KEY = "store_id"
|
||||
|
||||
@Service
|
||||
class AuthService(
|
||||
@ -34,7 +35,6 @@ class AuthService(
|
||||
context: LoginContext
|
||||
): LoginSuccessResponse {
|
||||
log.info { "[AuthService.login] 로그인 시작: account=${request.account}, type=${request.principalType}, context=${context}" }
|
||||
|
||||
val (credentials, extraClaims) = getCredentials(request)
|
||||
|
||||
try {
|
||||
@ -44,7 +44,7 @@ class AuthService(
|
||||
|
||||
loginHistoryService.createSuccessHistory(credentials.id, request.principalType, context)
|
||||
|
||||
return LoginSuccessResponse(accessToken).also {
|
||||
return credentials.toResponse(accessToken).also {
|
||||
log.info { "[AuthService.login] 로그인 완료: account=${request.account}, context=${context}" }
|
||||
}
|
||||
|
||||
@ -97,15 +97,14 @@ class AuthService(
|
||||
val credentials: LoginCredentials = when (request.principalType) {
|
||||
PrincipalType.ADMIN -> {
|
||||
adminService.findCredentialsByAccount(request.account).also {
|
||||
extraClaims.put(CLAIM_PERMISSION_KEY, it.permissionLevel)
|
||||
extraClaims.put(CLAIM_TYPE_KEY, PrincipalType.ADMIN)
|
||||
extraClaims.put(CLAIM_ADMIN_TYPE_KEY, it.type.name)
|
||||
extraClaims.put(CLAIM_PERMISSION_KEY, it.permissionLevel.name)
|
||||
it.storeId?.also { storeId -> extraClaims.put(CLAIM_STORE_ID_KEY, storeId.toString()) }
|
||||
}
|
||||
}
|
||||
|
||||
PrincipalType.USER -> {
|
||||
userService.findCredentialsByAccount(request.account).also {
|
||||
extraClaims.put(CLAIM_TYPE_KEY, PrincipalType.USER)
|
||||
}
|
||||
userService.findCredentialsByAccount(request.account)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user