From cf8d94776e31663fbb618228002f920155b7f4ee Mon Sep 17 00:00:00 2001 From: Klaus Date: Fri, 3 Nov 2023 15:49:34 +0900 Subject: [PATCH 1/2] =?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다시 시도해 주세요.") } } } -- 2.40.1 From 97e80a85e0c3aed3d06408844017e64fda61860c Mon Sep 17 00:00:00 2001 From: Klaus Date: Fri, 3 Nov 2023 16:05:49 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=EB=B3=B8=EC=9D=B8=EC=9D=B8=EC=A6=9D=20-=20?= =?UTF-8?q?3=EA=B0=9C=20=EC=9D=B4=EC=83=81=EC=9D=98=20=EA=B3=84=EC=A0=95?= =?UTF-8?q?=EC=97=90=20=EB=B3=B8=EC=9D=B8=EC=9D=B8=EC=A6=9D=EC=9D=84=20?= =?UTF-8?q?=ED=95=98=EB=A0=A4=EA=B3=A0=20=EC=8B=9C=EB=8F=84=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20'=EC=9D=B4=EB=AF=B8=20?= =?UTF-8?q?=EB=B3=B8=EC=9D=B8=EC=9D=B8=EC=A6=9D=ED=95=9C=20=EA=B3=84?= =?UTF-8?q?=EC=A0=95=20N=EA=B0=9C=20=EC=9D=B4=EC=9A=A9=EC=A4=91=EC=9E=85?= =?UTF-8?q?=EB=8B=88=EB=8B=A4.=20=EC=86=8C=EB=8B=A4=EB=9D=BC=EC=9D=B4?= =?UTF-8?q?=EB=B8=8C=EC=9D=98=20=EB=B3=B8=EC=9D=B8=EC=9D=B8=EC=A6=9D?= =?UTF-8?q?=EC=9D=80=20=EC=B5=9C=EB=8C=80=203=EA=B0=9C=EC=9D=98=20?= =?UTF-8?q?=EA=B3=84=EC=A0=95=EB=A7=8C=20=EC=9D=B4=EC=9A=A9=ED=95=A0=20?= =?UTF-8?q?=EC=88=98=20=EC=9E=88=EC=8A=B5=EB=8B=88=EB=8B=A4.'=20=EB=A9=94?= =?UTF-8?q?=EC=8B=9C=EC=A7=80=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sodalive/member/auth/AuthRepository.kt | 14 +++++++++++++- .../vividnext/sodalive/member/auth/AuthService.kt | 8 ++++++++ 2 files changed, 21 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 f08e337..0fe96e5 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,8 +13,8 @@ interface AuthRepository : JpaRepository, AuthQueryRepository interface AuthQueryRepository { fun getOldestCreatedAtByDi(di: String): LocalDateTime fun getMemberIdsByDi(di: String): List - fun getAuthIdByMemberId(memberId: Long): Long? + fun getActiveMemberIdsByDi(di: String): List } class AuthQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : AuthQueryRepository { @@ -44,4 +44,16 @@ class AuthQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : AuthQ .where(auth.member.id.eq(memberId)) .fetchFirst() } + + override fun getActiveMemberIdsByDi(di: String): List { + return queryFactory + .select(member.id) + .from(member) + .leftJoin(member.auth, auth) + .where( + auth.di.eq(di) + .and(member.isActive.isTrue) + ) + .fetch() + } } 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 aa7566d..a7a09f3 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 @@ -43,6 +43,14 @@ class AuthService( val nowYear = LocalDate.now().year val certificateYear = certificate.birth.substring(0, 4).toInt() if (nowYear - certificateYear >= 19) { + val memberIds = repository.getActiveMemberIdsByDi(di = certificate.di) + if (memberIds.size >= 3) { + throw SodaException( + "이미 본인인증한 계정 ${memberIds.size}개 이용중입니다.\n" + + "소다라이브의 본인인증은 최대 3개의 계정만 이용할 수 있습니다." + ) + } + val auth = Auth( name = certificate.name, birth = certificate.birth, -- 2.40.1