From cf8d94776e31663fbb618228002f920155b7f4ee Mon Sep 17 00:00:00 2001 From: Klaus Date: Fri, 3 Nov 2023 15:49:34 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B3=B8=EC=9D=B8=EC=9D=B8=EC=A6=9D=20-=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=20=EB=B3=B8=EC=9D=B8=EC=9D=B8=EC=A6=9D?= =?UTF-8?q?=EC=9D=84=20=ED=95=9C=20=EA=B3=84=EC=A0=95=EC=9D=98=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=20'=EC=9D=B4=EB=AF=B8=20=EC=9D=B8=EC=A6=9D=EB=90=9C?= =?UTF-8?q?=20=EA=B3=84=EC=A0=95=EC=9E=85=EB=8B=88=EB=8B=A4.'=20=EB=AC=B8?= =?UTF-8?q?=EA=B5=AC=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vividnext/sodalive/member/auth/AuthRepository.kt | 11 +++++++++++ .../co/vividnext/sodalive/member/auth/AuthService.kt | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) 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다시 시도해 주세요.") } } }