Skip to content

Commit

Permalink
Merge pull request #141 from TeamMiso/hotfix/password-check
Browse files Browse the repository at this point in the history
๐Ÿ”€ :: ๋กœ๊ทธ์ธ ๊ณผ์ •์—์„œ ๋น„๋ฐ€๋ฒˆํ˜ธ ์ผ์น˜ ๊ฒ€์‚ฌ๋ฅผ ์ œ๋Œ€๋กœ ์ˆ˜ํ–‰ํ•˜์ง€ ์•Š๊ณ  ์žˆ๋˜ ์˜ค๋ฅ˜ ์ˆ˜์ •
  • Loading branch information
uuuuuuuk authored Aug 28, 2024
2 parents b73dba5 + 77328b6 commit 028d59f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
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

0 comments on commit 028d59f

Please sign in to comment.