본인인증 - 이미 본인인증을 한 계정의 경우 '이미 인증된 계정입니다.' 문구 반환
This commit is contained in:
		| @@ -13,6 +13,8 @@ interface AuthRepository : JpaRepository<Auth, Long>, AuthQueryRepository | ||||
| interface AuthQueryRepository { | ||||
|     fun getOldestCreatedAtByDi(di: String): LocalDateTime | ||||
|     fun getMemberIdsByDi(di: String): List<Long> | ||||
|  | ||||
|     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() | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -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다시 시도해 주세요.") | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user