diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/member/auth/AuthRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/member/auth/AuthRepository.kt index 1ee9747..f08e337 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/member/auth/AuthRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/member/auth/AuthRepository.kt @@ -13,6 +13,8 @@ interface AuthRepository : JpaRepository, AuthQueryRepository interface AuthQueryRepository { fun getOldestCreatedAtByDi(di: String): LocalDateTime fun getMemberIdsByDi(di: String): List + + fun getAuthIdByMemberId(memberId: Long): Long? } class AuthQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : AuthQueryRepository { @@ -33,4 +35,13 @@ class AuthQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : AuthQ .where(auth.di.eq(di)) .fetch() } + + override fun getAuthIdByMemberId(memberId: Long): Long? { + return queryFactory + .select(auth.id) + .from(auth) + .innerJoin(auth.member, member) + .where(auth.member.id.eq(memberId)) + .fetchFirst() + } } diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/member/auth/AuthService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/member/auth/AuthService.kt index 76af74e..aa7566d 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/member/auth/AuthService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/member/auth/AuthService.kt @@ -23,6 +23,10 @@ class AuthService( @Transactional fun verify(member: Member, request: AuthVerifyRequest) { val bootpay = Bootpay(bootpayApplicationId, bootpayPrivateKey) + + val authId = repository.getAuthIdByMemberId(memberId = member.id!!) + if (authId != null) throw SodaException("이미 인증된 계정입니다.") + try { val token = bootpay.accessToken if (token["error_code"] != null) throw SodaException("인증정보에 오류가 있습니다.\n다시 시도해 주세요.") @@ -56,7 +60,7 @@ class AuthService( throw SodaException("인증정보에 오류가 있습니다.\n다시 시도해 주세요.") } } catch (e: Exception) { - throw SodaException("인증정보에 오류가 있습니다.\n다시 시도해 주세요.") + throw SodaException(e.message ?: "인증정보에 오류가 있습니다.\n다시 시도해 주세요.") } } }