parent
75140a4055
commit
60012a7aad
|
@ -40,58 +40,60 @@ class AuthService(
|
||||||
val authId = repository.getAuthIdByMemberId(memberId = memberId)
|
val authId = repository.getAuthIdByMemberId(memberId = memberId)
|
||||||
if (authId != null) throw SodaException("이미 인증된 계정입니다.")
|
if (authId != null) throw SodaException("이미 인증된 계정입니다.")
|
||||||
|
|
||||||
try {
|
val certificateResult: AuthCertificateResult = try {
|
||||||
val token = bootpay.accessToken
|
val token = bootpay.accessToken
|
||||||
if (token["error_code"] != null) throw SodaException("인증정보에 오류가 있습니다.\n다시 시도해 주세요.")
|
if (token["error_code"] != null) throw SodaException("인증정보에 오류가 있습니다.\n다시 시도해 주세요.")
|
||||||
|
|
||||||
val res = bootpay.certificate(request.receiptId)
|
val res = bootpay.certificate(request.receiptId)
|
||||||
val certificateResult = objectMapper.convertValue(res, AuthCertificateResult::class.java)
|
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다시 시도해 주세요.")
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
throw SodaException(e.message ?: "인증정보에 오류가 있습니다.\n다시 시도해 주세요.")
|
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 {
|
private fun isBlockAuth(certificate: AuthVerifyCertificate): Boolean {
|
||||||
|
|
Loading…
Reference in New Issue