Skip to content

Commit

Permalink
Add Validate Soft Deleted In User Creation
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Diger committed Dec 26, 2023
1 parent 3152b21 commit a968392
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class AuthApplicationService(
fun kakaoLogin(accessToken: String): LoginResponse {
val kakaoId = authService.verifyKaKao(accessToken)
val user = userService.loadByOAuthPayload(kakaoId)

if (user == null) {
val newUser = userService.create(
User(
Expand All @@ -39,6 +40,11 @@ class AuthApplicationService(
)
return buildLoginResponseByNewUser(newUser)
}

if (user.deletedAt != null) {
userService.convertBySoftDeleteToEntity(user.id!!)
}

return buildLoginResponseByUser(user)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ fun UserEntity.disable() {
this.deletedAt = LocalDateTime.now()
}

fun UserEntity.able() {
this.deletedAt = null
}

@Embeddable
data class Nickname(
@Column(name = "nickname")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,10 @@ class UserService(
val userEntity = loadById(id).fromDto()
userEntity.disable()
}

@Transactional
fun convertBySoftDeleteToEntity(id: Long) {
val userEntity = loadById(id).fromDto()
userEntity.able()
}
}

0 comments on commit a968392

Please sign in to comment.