diff --git a/src/main/kotlin/com/msg/gauth/domain/client/exception/InvalidDelegateUserException.kt b/src/main/kotlin/com/msg/gauth/domain/client/exception/InvalidDelegateUserException.kt new file mode 100644 index 00000000..711734bb --- /dev/null +++ b/src/main/kotlin/com/msg/gauth/domain/client/exception/InvalidDelegateUserException.kt @@ -0,0 +1,6 @@ +package com.msg.gauth.domain.client.exception + +import com.msg.gauth.global.exception.ErrorCode +import com.msg.gauth.global.exception.exceptions.BasicException + +class InvalidDelegateUserException: BasicException(ErrorCode.INVALID_DELEGATE_USER) \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/domain/client/service/DelegateOwnerService.kt b/src/main/kotlin/com/msg/gauth/domain/client/service/DelegateOwnerService.kt index 95a948b8..706e9a14 100644 --- a/src/main/kotlin/com/msg/gauth/domain/client/service/DelegateOwnerService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/client/service/DelegateOwnerService.kt @@ -3,8 +3,10 @@ package com.msg.gauth.domain.client.service import com.msg.gauth.domain.client.Client import com.msg.gauth.domain.client.exception.BadDelegateUserIdRequestException import com.msg.gauth.domain.client.exception.ClientNotFindException +import com.msg.gauth.domain.client.exception.InvalidDelegateUserException import com.msg.gauth.domain.client.exception.UserNotMatchException import com.msg.gauth.domain.client.repository.ClientRepository +import com.msg.gauth.domain.user.enums.UserRoleType import com.msg.gauth.domain.user.exception.UserNotFoundException import com.msg.gauth.domain.user.repository.UserRepository import com.msg.gauth.domain.user.util.UserUtil @@ -33,6 +35,9 @@ class DelegateOwnerService( val delegateUser = userRepository.findByIdOrNull(delegateUserId) ?: throw UserNotFoundException() + if (delegateUser.userRole.any { it.userRoleType != UserRoleType.ROLE_STUDENT }) + throw InvalidDelegateUserException() + val updateClient = Client( id = client.id, clientId = client.clientId, diff --git a/src/main/kotlin/com/msg/gauth/global/exception/ErrorCode.kt b/src/main/kotlin/com/msg/gauth/global/exception/ErrorCode.kt index 5814f1f2..2d4ddc37 100644 --- a/src/main/kotlin/com/msg/gauth/global/exception/ErrorCode.kt +++ b/src/main/kotlin/com/msg/gauth/global/exception/ErrorCode.kt @@ -9,6 +9,7 @@ enum class ErrorCode( CLIENT_SECRET_MISMATCH("클라이언트 시크릿이 일치하지 않습니다.", 400), FILE_EXTENSION_INVALID("파일 확장자가 유효하지 않습니다.", 400), ALREADY_AUTHENTICATED_MAIL("이미 인증된 메일 입니다.", 400), + INVALID_DELEGATE_USER("유효하지 않은 위임자입니다.", 400), AUTH_CODE_EXPIRED("메일 인증이 만료되었습니다.", 401), UNAUTHORIZED("권한 없음", 401),