From fa955101fac1305c5595baf7293b382b102ef58d Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Tue, 7 May 2024 22:35:17 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20invoke=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=9B=90=EC=83=81=EB=B3=B5=EA=B5=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/command/AuthInvoker.kt | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/auth/application/service/command/AuthInvoker.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/auth/application/service/command/AuthInvoker.kt index 136da882..afe989ac 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/auth/application/service/command/AuthInvoker.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/auth/application/service/command/AuthInvoker.kt @@ -13,22 +13,21 @@ import org.springframework.stereotype.Component class AuthInvoker ( private val authHandlerList: List, private val jwtProvider: JwtProvider, -// private val userReader: UserReader + private val userReader: UserReader ) { fun invoke(request: SocialLogin.Request, provider: SocialLoginProvider): SocialLogin.Response { val response = attemptLogin(request, provider) - return SocialLogin.Response.UnRegistered("registrationToken", response.nickName) -// return TransactionUtils.writable { -// return@writable userReader.findBySocialIdOrNull(response.socialId)?.let { -// val accessToken = jwtProvider.generateAccessToken(Claims.UserClaims(it.id)) -// val refreshToken = jwtProvider.generateRefreshToken(Claims.UserClaims(it.id)) -// SocialLogin.Response.Success(accessToken, refreshToken) -// } ?: run { -// val registrationToken = jwtProvider.generateRegistrationToken(Claims.RegistrationClaims(response.socialId, provider)) -// SocialLogin.Response.UnRegistered(registrationToken, response.nickName) -// } -// } + return TransactionUtils.writable { + return@writable userReader.findBySocialIdOrNull(response.socialId)?.let { + val accessToken = jwtProvider.generateAccessToken(Claims.UserClaims(it.id)) + val refreshToken = jwtProvider.generateRefreshToken(Claims.UserClaims(it.id)) + SocialLogin.Response.Success(accessToken, refreshToken) + } ?: run { + val registrationToken = jwtProvider.generateRegistrationToken(Claims.RegistrationClaims(response.socialId, provider)) + SocialLogin.Response.UnRegistered(registrationToken, response.nickName) + } + } } private fun attemptLogin(request: SocialLogin.Request, provider: SocialLoginProvider): AuthHandler.Response {