Skip to content

Commit

Permalink
Merge pull request #181 from GSM-MSG/feature/180-reset-wrong-password…
Browse files Browse the repository at this point in the history
…-count

🔀  :: 180 - 로그인 성공시 틀린 횟수 초기화
  • Loading branch information
dolong2 authored Jun 28, 2023
2 parents b8d5d2d + 8c4e9a9 commit 70f749e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ class SignInService(
throw PasswordMismatchException()
}

if(user.state != UserState.CREATED)
if(user.state == UserState.PENDING)
throw UserIsPendingException()

tempUserUtil.resetWrongPasswordCount(user)

val (access, refresh) = jwtTokenProvider.run {
generateAccessToken(dto.email) to generateRefreshToken(dto.email)}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class GenerateOauthCodeService(
if(user.state == UserState.PENDING)
throw UserStatePendingException()

tempUserUtil.resetOAuthWrongPasswordCount(user)

val code = UUID.randomUUID().toString().split(".")[0]

oauthCodeRepository.save(OauthCode(code, user.email))
Expand Down
40 changes: 40 additions & 0 deletions src/main/kotlin/com/msg/gauth/domain/user/util/TempUserUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,44 @@ class TempUserUtil(
tempOAuthSignInBanRepository.existsById(user.email) -> throw TempSignInBanException()
}
}

fun resetOAuthWrongPasswordCount(user: User) {
userRepository.save(
User(
id = user.id,
email = user.email,
password = user.password,
gender = user.gender,
name = user.name,
grade = user.grade,
classNum = user.classNum,
num = user.num,
roles = user.roles,
state = user.state,
profileUrl = user.profileUrl,
wrongPasswordCount = user.wrongPasswordCount,
oauthWrongPasswordCount = 0
)
)
}

fun resetWrongPasswordCount(user: User) {
userRepository.save(
User(
id = user.id,
email = user.email,
password = user.password,
gender = user.gender,
name = user.name,
grade = user.grade,
classNum = user.classNum,
num = user.num,
roles = user.roles,
state = user.state,
profileUrl = user.profileUrl,
wrongPasswordCount = 0,
oauthWrongPasswordCount = user.oauthWrongPasswordCount
)
)
}
}

0 comments on commit 70f749e

Please sign in to comment.