소셜 로그인 리졸버 도입
This commit is contained in:
@@ -13,8 +13,7 @@ import kr.co.vividnext.sodalive.member.login.LoginResponse
|
||||
import kr.co.vividnext.sodalive.member.login.SocialLoginRequest
|
||||
import kr.co.vividnext.sodalive.member.notification.UpdateNotificationSettingRequest
|
||||
import kr.co.vividnext.sodalive.member.signUp.SignUpRequestV2
|
||||
import kr.co.vividnext.sodalive.member.social.google.GoogleAuthService
|
||||
import kr.co.vividnext.sodalive.member.social.kakao.KakaoAuthService
|
||||
import kr.co.vividnext.sodalive.member.social.SocialAuthServiceResolver
|
||||
import kr.co.vividnext.sodalive.useraction.ActionType
|
||||
import kr.co.vividnext.sodalive.useraction.UserActionService
|
||||
import org.springframework.data.domain.Pageable
|
||||
@@ -36,8 +35,7 @@ import org.springframework.web.multipart.MultipartFile
|
||||
@RequestMapping("/member")
|
||||
class MemberController(
|
||||
private val service: MemberService,
|
||||
private val kakaoAuthService: KakaoAuthService,
|
||||
private val googleAuthService: GoogleAuthService,
|
||||
private val socialAuthServiceResolver: SocialAuthServiceResolver,
|
||||
private val trackingService: AdTrackingService,
|
||||
private val userActionService: UserActionService,
|
||||
private val messageSource: SodaMessageSource,
|
||||
@@ -345,31 +343,7 @@ class MemberController(
|
||||
@RequestHeader("Authorization") authHeader: String,
|
||||
@RequestBody request: SocialLoginRequest
|
||||
): ApiResponse<LoginResponse> {
|
||||
if (!authHeader.startsWith("Bearer ")) {
|
||||
throw SodaException(messageKey = "member.social.google_login_failed")
|
||||
}
|
||||
|
||||
val token = authHeader.substring(7)
|
||||
val response = googleAuthService.authenticate(token, request.container, request.marketingPid, request.pushToken)
|
||||
|
||||
if (!response.marketingPid.isNullOrBlank()) {
|
||||
trackingService.saveTrackingHistory(
|
||||
pid = response.marketingPid,
|
||||
type = AdTrackingHistoryType.SIGNUP,
|
||||
memberId = response.memberId
|
||||
)
|
||||
}
|
||||
|
||||
if (response.isNew) {
|
||||
userActionService.recordAction(
|
||||
memberId = response.memberId,
|
||||
isAuth = false,
|
||||
actionType = ActionType.SIGN_UP
|
||||
)
|
||||
}
|
||||
|
||||
val message = messageSource.getMessage("member.signup.success", langContext.lang)
|
||||
return ApiResponse.ok(message = message, data = response.loginResponse)
|
||||
return processSocialLogin(MemberProvider.GOOGLE, authHeader, request)
|
||||
}
|
||||
|
||||
@PostMapping("/login/kakao")
|
||||
@@ -377,12 +351,27 @@ class MemberController(
|
||||
@RequestHeader("Authorization") authHeader: String,
|
||||
@RequestBody request: SocialLoginRequest
|
||||
): ApiResponse<LoginResponse> {
|
||||
return processSocialLogin(MemberProvider.KAKAO, authHeader, request)
|
||||
}
|
||||
|
||||
private fun processSocialLogin(
|
||||
provider: MemberProvider,
|
||||
authHeader: String,
|
||||
request: SocialLoginRequest
|
||||
): ApiResponse<LoginResponse> {
|
||||
val errorKey = when (provider) {
|
||||
MemberProvider.GOOGLE -> "member.social.google_login_failed"
|
||||
MemberProvider.KAKAO -> "member.social.kakao_login_failed"
|
||||
else -> "common.error.bad_request"
|
||||
}
|
||||
|
||||
if (!authHeader.startsWith("Bearer ")) {
|
||||
throw SodaException(messageKey = "member.social.kakao_login_failed")
|
||||
throw SodaException(messageKey = errorKey)
|
||||
}
|
||||
|
||||
val token = authHeader.substring(7)
|
||||
val response = kakaoAuthService.authenticate(token, request.container, request.marketingPid, request.pushToken)
|
||||
val authService = socialAuthServiceResolver.resolve(provider)
|
||||
val response = authService.authenticate(token, request.container, request.marketingPid, request.pushToken)
|
||||
|
||||
if (!response.marketingPid.isNullOrBlank()) {
|
||||
trackingService.saveTrackingHistory(
|
||||
|
||||
Reference in New Issue
Block a user