Skip to content

Commit

Permalink
email 중복 데이터 필터링 (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hank-Choi authored Oct 2, 2024
1 parent 4dae8d7 commit ef909e2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 0 additions & 2 deletions core/src/main/kotlin/users/repository/UserRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ interface UserRepository : CoroutineCrudRepository<User, String> {

suspend fun findAllByIdInAndActiveTrue(ids: List<String>): List<User>

suspend fun findByEmailAndActiveTrue(email: String): User?

suspend fun existsByEmailAndIsEmailVerifiedTrueAndActiveTrue(email: String): Boolean

suspend fun findByEmailAndIsEmailVerifiedTrueAndActiveTrue(email: String): User?
Expand Down
6 changes: 2 additions & 4 deletions core/src/main/kotlin/users/service/UserService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -489,14 +489,12 @@ class UserServiceImpl(
}

override suspend fun sendLocalIdToEmail(email: String) {
if (!authService.isValidEmail(email)) throw InvalidEmailException
val user = userRepository.findByEmailAndActiveTrue(email) ?: throw UserNotFoundException
val user = userRepository.findByEmailAndIsEmailVerifiedTrueAndActiveTrue(email) ?: throw UserNotFoundException
mailService.sendUserMail(type = UserMailType.FIND_ID, to = email, localId = user.credential.localId ?: throw UserNotFoundException)
}

override suspend fun sendResetPasswordCode(email: String) {
if (!authService.isValidEmail(email)) throw InvalidEmailException
val user = userRepository.findByEmailAndActiveTrue(email) ?: throw UserNotFoundException
val user = userRepository.findByEmailAndIsEmailVerifiedTrueAndActiveTrue(email) ?: throw UserNotFoundException
val key = RESET_PASSWORD_CODE_PREFIX + user.id
val code = Base64.getUrlEncoder().encodeToString(Random.nextBytes(6))
saveNewVerificationValue(email, code, key)
Expand Down

0 comments on commit ef909e2

Please sign in to comment.