본인인증 : block 된 사용자 정보로 본인인증을 시도하는 경우
- 본인인증 시도 계정 탈퇴 처리
This commit is contained in:
		| @@ -19,6 +19,14 @@ class AuthController(private val service: AuthService) { | ||||
|     ) = run { | ||||
|         if (member == null) throw SodaException("로그인 정보를 확인해주세요.") | ||||
|  | ||||
|         ApiResponse.ok(service.verify(member.id!!, request)) | ||||
|         val authenticateData = service.certificate(request, memberId = member.id!!) | ||||
|  | ||||
|         if (service.isBlockAuth(authenticateData)) { | ||||
|             service.signOut(member.id!!) | ||||
|         } else { | ||||
|             service.authenticate(authenticateData, member.id!!) | ||||
|         } | ||||
|  | ||||
|         ApiResponse.ok(null, null) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -11,7 +11,6 @@ import org.springframework.beans.factory.annotation.Value | ||||
| import org.springframework.data.repository.findByIdOrNull | ||||
| import org.springframework.stereotype.Service | ||||
| import org.springframework.transaction.annotation.Transactional | ||||
| import java.time.LocalDate | ||||
|  | ||||
| @Service | ||||
| class AuthService( | ||||
| @@ -30,7 +29,7 @@ class AuthService( | ||||
| ) { | ||||
|     private val blockMessage = "운영정책을 위반하여 이용을 제한합니다." | ||||
|  | ||||
|     fun verify(memberId: Long, request: AuthVerifyRequest) { | ||||
|     fun certificate(request: AuthVerifyRequest, memberId: Long): AuthVerifyCertificate { | ||||
|         val bootpay = Bootpay(bootpayApplicationId, bootpayPrivateKey) | ||||
|  | ||||
|         val authId = repository.getAuthIdByMemberId(memberId = memberId) | ||||
| @@ -51,41 +50,27 @@ class AuthService( | ||||
|             certificateResult.statusLocale == "본인인증완료" && | ||||
|             certificateResult.receiptId == request.receiptId | ||||
|         ) { | ||||
|             val certificate = certificateResult.authenticateData | ||||
|             if (!checkBlockAuth(certificate, memberId)) { | ||||
|                 throw SodaException(blockMessage) | ||||
|             } else { | ||||
|                 val nowYear = LocalDate.now().year | ||||
|                 val certificateYear = certificate.birth.substring(0, 4).toInt() | ||||
|  | ||||
|                 if (nowYear - certificateYear >= 19) { | ||||
|                     authenticate(certificate, memberId) | ||||
|                 } else { | ||||
|                     throw SodaException("19세 미만 인증 오류") | ||||
|                 } | ||||
|             } | ||||
|             return certificateResult.authenticateData | ||||
|         } else { | ||||
|             throw SodaException("인증정보에 오류가 있습니다.\n다시 시도해 주세요.") | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Transactional | ||||
|     fun checkBlockAuth(certificate: AuthVerifyCertificate, memberId: Long): Boolean { | ||||
|     fun isBlockAuth(certificate: AuthVerifyCertificate): Boolean { | ||||
|         val blockAuthId = blockAuthRepository.findByUniqueCiAndDi(certificate.unique, certificate.di) | ||||
|         if (blockAuthId != null && blockAuthId > 0) { | ||||
|             val member = memberRepository.findByIdOrNull(memberId) ?: throw SodaException("로그인 정보를 확인해주세요.") | ||||
|             member.isActive = false | ||||
|         return blockAuthId != null && blockAuthId > 0 | ||||
|     } | ||||
|  | ||||
|             val signOut = SignOut(reason = blockMessage) | ||||
|             signOut.member = member | ||||
|             signOutRepository.save(signOut) | ||||
|     @Transactional | ||||
|     fun signOut(memberId: Long) { | ||||
|         val member = memberRepository.findByIdOrNull(memberId) ?: throw SodaException("로그인 정보를 확인해주세요.") | ||||
|         member.isActive = false | ||||
|  | ||||
|             memberService.logoutAll(memberId = member.id!!) | ||||
|         val signOut = SignOut(reason = blockMessage) | ||||
|         signOut.member = member | ||||
|         signOutRepository.save(signOut) | ||||
|  | ||||
|             return true | ||||
|         } | ||||
|  | ||||
|         return false | ||||
|         memberService.logoutAll(memberId = memberId) | ||||
|     } | ||||
|  | ||||
|     @Transactional | ||||
|   | ||||
		Reference in New Issue
	
	Block a user