Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

๐Ÿ”€ :: ๋กœ๊ทธ์ธ ๊ณผ์ •์—์„œ ๋น„๋ฐ€๋ฒˆํ˜ธ ์ผ์น˜ ๊ฒ€์‚ฌ๋ฅผ ์ œ๋Œ€๋กœ ์ˆ˜ํ–‰ํ•˜์ง€ ์•Š๊ณ  ์žˆ๋˜ ์˜ค๋ฅ˜ ์ˆ˜์ • #141

Merged
merged 3 commits into from
Aug 28, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import andreas311.miso.domain.auth.application.event.SaveRefreshTokenEvent
import andreas311.miso.domain.auth.application.exception.EmailNotValidException
import andreas311.miso.domain.auth.application.port.input.SignInUseCase
import andreas311.miso.domain.auth.application.port.input.dto.SignInDto
import andreas311.miso.domain.auth.application.port.output.PasswordEncodePort
import andreas311.miso.domain.auth.application.port.output.TokenGeneratePort
import andreas311.miso.domain.auth.application.port.output.dto.TokenDto
import andreas311.miso.domain.email.application.port.output.QueryEmailPort
Expand All @@ -18,6 +19,7 @@ class SignInService(
private val queryUserPort: QueryUserPort,
private val queryEmailPort: QueryEmailPort,
private val tokenGeneratePort: TokenGeneratePort,
private val passwordEncodePort: PasswordEncodePort,
private val applicationEventPublisher: ApplicationEventPublisher
) : SignInUseCase {
override fun execute(signInDto: SignInDto): TokenDto {
Expand All @@ -30,6 +32,8 @@ class SignInService(
throw EmailNotValidException()
}

passwordEncodePort.isPasswordMatch(signInDto.password, user.password)

val token = tokenGeneratePort.generateToken(signInDto.email, user.role)

publishSaveRefreshToken(token, user)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package andreas311.miso.domain.auth.application.service

import andreas311.miso.common.annotation.RollbackService
import andreas311.miso.domain.auth.application.exception.MismatchPasswordException
import andreas311.miso.domain.auth.application.exception.UserAlreadyExistException
import andreas311.miso.domain.auth.application.port.input.SignUpUseCase
import andreas311.miso.domain.auth.application.port.input.dto.SignUpDto
Expand All @@ -24,7 +25,9 @@ class SignUpService(
private val passwordEncodePort: PasswordEncodePort
) : SignUpUseCase {
override fun execute(signUpDto: SignUpDto) {
passwordEncodePort.isPasswordMatch(signUpDto.password, signUpDto.passwordCheck)
if (signUpDto.password != signUpDto.passwordCheck) {
throw MismatchPasswordException()
}

if (!queryUserPort.existsByEmail(signUpDto.email)) {
emailSendPort.sendEmailAuthKey(signUpDto.email)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class PasswordEncodeAdapter(
override fun passwordEncode(password: String): String =
passwordEncoder.encode(password)

override fun isPasswordMatch(password: String, passwordCheck: String) {
if (password != passwordCheck) {
override fun isPasswordMatch(passwordCheck: String, password: String) {
if (!passwordEncoder.matches(passwordCheck, password)) {
throw MismatchPasswordException()
}
}
Expand Down
Loading