Skip to content

Commit

Permalink
feat: user 상태 별 접근 제한 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
wjdtkdgns committed Jun 5, 2024
1 parent a880969 commit b3fefa6
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import com.balancemania.api.auth.model.TokenDto
import com.balancemania.api.auth.model.response.TokenRefreshRequest
import com.balancemania.api.config.database.TransactionTemplates
import com.balancemania.api.exception.ErrorCode
import com.balancemania.api.exception.InvalidRequestException
import com.balancemania.api.exception.InvalidTokenException
import com.balancemania.api.exception.NoAuthorityException
import com.balancemania.api.extension.coExecuteOrNull
import com.balancemania.api.user.application.UserService
import com.balancemania.api.user.domain.vo.UserStatusType
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.coroutineScope
Expand All @@ -38,6 +40,16 @@ class AuthFacade(

val user = userService.findByIdOrThrowSync(payload.id)

when (user.statusType) {
UserStatusType.ACTIVE -> {
/** 별도 처리 없음 */
}

UserStatusType.DELETED -> throw InvalidRequestException(ErrorCode.WITHDRAW_USER_ERROR)
UserStatusType.BANISHED -> throw InvalidRequestException(ErrorCode.BANISHED_USER_ERROR)
UserStatusType.RESTRICTED_7_DAYS -> throw InvalidRequestException(ErrorCode.RESTRICTED_7_DAYS_USER_ERROR)
}

AuthUserImpl(uid = user.id)
}
}
Expand Down Expand Up @@ -78,6 +90,7 @@ class AuthFacade(
txTemplates.writer.coExecuteOrNull {
user.apply {
this.oauthInfo = oauthInfo.withdrawOAuthInfo()
this.statusType = UserStatusType.DELETED
}.run { userService.saveSync(this) }
}
}
Expand Down

0 comments on commit b3fefa6

Please sign in to comment.