diff --git a/src/main/kotlin/team/underlive/underlive/domain/auth/service/AuthService.kt b/src/main/kotlin/team/underlive/underlive/domain/auth/service/AuthService.kt index 19bcb3b..87d3ebf 100644 --- a/src/main/kotlin/team/underlive/underlive/domain/auth/service/AuthService.kt +++ b/src/main/kotlin/team/underlive/underlive/domain/auth/service/AuthService.kt @@ -16,7 +16,7 @@ import team.underlive.underlive.global.exception.error.HttpException @Service class AuthService( private val userRepository: UserRepository, - private val passwordEncoder: PasswordEncoder + private val passwordEncoder: PasswordEncoder, ) { fun createUser(userJoinRequest: UserJoinRequest) { if (userRepository.existsByEmail(userJoinRequest.email)) { @@ -36,14 +36,14 @@ class AuthService( } fun loginUser(userLoginRequest: UserLoginRequest): UserLoginResponse { - val user = userRepository.findByEmail(userLoginRequest.email) - .orElseThrow { HttpException(HttpStatus.NOT_FOUND, "해당 이메일을 사용하는 유저를 찾을 수 없습니다.") } - - if(!passwordEncoder.matches(userLoginRequest.password, user.password)){ - throw HttpException(HttpStatus.BAD_REQUEST, "비밀번호가 일치하지 않습니다.") - } - + val user = + userRepository.findByEmail(userLoginRequest.email) + .orElseThrow { HttpException(HttpStatus.NOT_FOUND, "해당 이메일을 사용하는 유저를 찾을 수 없습니다.") } + if (!passwordEncoder.matches(userLoginRequest.password, user.password)) + { + throw HttpException(HttpStatus.BAD_REQUEST, "비밀번호가 일치하지 않습니다.") + } return UserLoginResponse("test", "test") } diff --git a/src/main/kotlin/team/underlive/underlive/domain/user/repository/UserRepository.kt b/src/main/kotlin/team/underlive/underlive/domain/user/repository/UserRepository.kt index fb375c2..bd71ec4 100644 --- a/src/main/kotlin/team/underlive/underlive/domain/user/repository/UserRepository.kt +++ b/src/main/kotlin/team/underlive/underlive/domain/user/repository/UserRepository.kt @@ -7,5 +7,6 @@ import java.util.UUID interface UserRepository : JpaRepository { fun existsByEmail(email: String): Boolean + fun findByEmail(email: String): Optional }