From 60012a7aad3abced6c3555c50f9a53ce46e45b03 Mon Sep 17 00:00:00 2001 From: Klaus Date: Thu, 9 Nov 2023 18:15:56 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B3=B8=EC=9D=B8=EC=9D=B8=EC=A6=9D=20:=20bloc?= =?UTF-8?q?k=20=EB=90=9C=20=EC=82=AC=EC=9A=A9=EC=9E=90=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=EB=A1=9C=20=EB=B3=B8=EC=9D=B8=EC=9D=B8=EC=A6=9D?= =?UTF-8?q?=EC=9D=84=20=EC=8B=9C=EB=8F=84=ED=95=98=EB=8A=94=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=20-=20=EB=B3=B8=EC=9D=B8=EC=9D=B8=EC=A6=9D=20?= =?UTF-8?q?=EC=8B=9C=EB=8F=84=20=EA=B3=84=EC=A0=95=20=ED=83=88=ED=87=B4=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sodalive/member/auth/AuthService.kt | 92 ++++++++++--------- 1 file changed, 47 insertions(+), 45 deletions(-) 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 67d7323..585f7c4 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 @@ -40,58 +40,60 @@ class AuthService( val authId = repository.getAuthIdByMemberId(memberId = memberId) if (authId != null) throw SodaException("이미 인증된 계정입니다.") - try { + val certificateResult: AuthCertificateResult = try { val token = bootpay.accessToken if (token["error_code"] != null) throw SodaException("인증정보에 오류가 있습니다.\n다시 시도해 주세요.") val res = bootpay.certificate(request.receiptId) - val certificateResult = objectMapper.convertValue(res, AuthCertificateResult::class.java) - - if ( - certificateResult.status == 12 && - certificateResult.statusLocale == "본인인증완료" && - certificateResult.receiptId == request.receiptId - ) { - val certificate = certificateResult.authenticateData - val nowYear = LocalDate.now().year - val certificateYear = certificate.birth.substring(0, 4).toInt() - - if (isBlockAuth(certificate)) { - try { - signOut(memberId = memberId) - } catch (_: Exception) { - } - throw SodaException(blockMessage) - } - - 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, - uniqueCi = certificate.unique, - di = certificate.di, - gender = certificate.gender - ) - auth.member = member - - repository.save(auth) - } else { - throw SodaException("19세 미만 인증 오류") - } - } else { - throw SodaException("인증정보에 오류가 있습니다.\n다시 시도해 주세요.") - } + objectMapper.convertValue(res, AuthCertificateResult::class.java) } catch (e: Exception) { throw SodaException(e.message ?: "인증정보에 오류가 있습니다.\n다시 시도해 주세요.") } + + if ( + certificateResult.status == 12 && + certificateResult.statusLocale == "본인인증완료" && + certificateResult.receiptId == request.receiptId + ) { + val certificate = certificateResult.authenticateData + + if (isBlockAuth(certificate)) { + try { + signOut(memberId = memberId) + } catch (_: Exception) { + } + + throw SodaException(blockMessage) + } + + 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, + uniqueCi = certificate.unique, + di = certificate.di, + gender = certificate.gender + ) + auth.member = member + + repository.save(auth) + } else { + throw SodaException("19세 미만 인증 오류") + } + } else { + throw SodaException("인증정보에 오류가 있습니다.\n다시 시도해 주세요.") + } } private fun isBlockAuth(certificate: AuthVerifyCertificate): Boolean {