본인인증 #64
| @@ -13,6 +13,8 @@ interface AuthRepository : JpaRepository<Auth, Long>, AuthQueryRepository | |||||||
| interface AuthQueryRepository { | interface AuthQueryRepository { | ||||||
|     fun getOldestCreatedAtByDi(di: String): LocalDateTime |     fun getOldestCreatedAtByDi(di: String): LocalDateTime | ||||||
|     fun getMemberIdsByDi(di: String): List<Long> |     fun getMemberIdsByDi(di: String): List<Long> | ||||||
|  |  | ||||||
|  |     fun getAuthIdByMemberId(memberId: Long): Long? | ||||||
| } | } | ||||||
|  |  | ||||||
| class AuthQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : AuthQueryRepository { | class AuthQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : AuthQueryRepository { | ||||||
| @@ -33,4 +35,13 @@ class AuthQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : AuthQ | |||||||
|             .where(auth.di.eq(di)) |             .where(auth.di.eq(di)) | ||||||
|             .fetch() |             .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 |     @Transactional | ||||||
|     fun verify(member: Member, request: AuthVerifyRequest) { |     fun verify(member: Member, request: AuthVerifyRequest) { | ||||||
|         val bootpay = Bootpay(bootpayApplicationId, bootpayPrivateKey) |         val bootpay = Bootpay(bootpayApplicationId, bootpayPrivateKey) | ||||||
|  |  | ||||||
|  |         val authId = repository.getAuthIdByMemberId(memberId = member.id!!) | ||||||
|  |         if (authId != null) throw SodaException("이미 인증된 계정입니다.") | ||||||
|  |  | ||||||
|         try { |         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다시 시도해 주세요.") | ||||||
| @@ -56,7 +60,7 @@ class AuthService( | |||||||
|                 throw SodaException("인증정보에 오류가 있습니다.\n다시 시도해 주세요.") |                 throw SodaException("인증정보에 오류가 있습니다.\n다시 시도해 주세요.") | ||||||
|             } |             } | ||||||
|         } catch (e: Exception) { |         } catch (e: Exception) { | ||||||
|             throw SodaException("인증정보에 오류가 있습니다.\n다시 시도해 주세요.") |             throw SodaException(e.message ?: "인증정보에 오류가 있습니다.\n다시 시도해 주세요.") | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user