본인인증 - 3개 이상의 계정에 본인인증을 하려고 시도하는 경우 '이미 본인인증한 계정 N개 이용중입니다. 소다라이브의 본인인증은 최대 3개의 계정만 이용할 수 있습니다.' 메시지 반환
This commit is contained in:
parent
cf8d94776e
commit
97e80a85e0
|
@ -13,8 +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?
|
fun getAuthIdByMemberId(memberId: Long): Long?
|
||||||
|
fun getActiveMemberIdsByDi(di: String): List<Long>
|
||||||
}
|
}
|
||||||
|
|
||||||
class AuthQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : AuthQueryRepository {
|
class AuthQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : AuthQueryRepository {
|
||||||
|
@ -44,4 +44,16 @@ class AuthQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : AuthQ
|
||||||
.where(auth.member.id.eq(memberId))
|
.where(auth.member.id.eq(memberId))
|
||||||
.fetchFirst()
|
.fetchFirst()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getActiveMemberIdsByDi(di: String): List<Long> {
|
||||||
|
return queryFactory
|
||||||
|
.select(member.id)
|
||||||
|
.from(member)
|
||||||
|
.leftJoin(member.auth, auth)
|
||||||
|
.where(
|
||||||
|
auth.di.eq(di)
|
||||||
|
.and(member.isActive.isTrue)
|
||||||
|
)
|
||||||
|
.fetch()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,14 @@ class AuthService(
|
||||||
val nowYear = LocalDate.now().year
|
val nowYear = LocalDate.now().year
|
||||||
val certificateYear = certificate.birth.substring(0, 4).toInt()
|
val certificateYear = certificate.birth.substring(0, 4).toInt()
|
||||||
if (nowYear - certificateYear >= 19) {
|
if (nowYear - certificateYear >= 19) {
|
||||||
|
val memberIds = repository.getActiveMemberIdsByDi(di = certificate.di)
|
||||||
|
if (memberIds.size >= 3) {
|
||||||
|
throw SodaException(
|
||||||
|
"이미 본인인증한 계정 ${memberIds.size}개 이용중입니다.\n" +
|
||||||
|
"소다라이브의 본인인증은 최대 3개의 계정만 이용할 수 있습니다."
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
val auth = Auth(
|
val auth = Auth(
|
||||||
name = certificate.name,
|
name = certificate.name,
|
||||||
birth = certificate.birth,
|
birth = certificate.birth,
|
||||||
|
|
Loading…
Reference in New Issue