From 977c96d9d0eeed4661db72ae694bfa459bd1352b Mon Sep 17 00:00:00 2001 From: Umjiseung <127853946+Umjiseung@users.noreply.github.com> Date: Wed, 6 Mar 2024 20:20:35 +0900 Subject: [PATCH 1/5] =?UTF-8?q?add=20::=20NotValidDelegateUserException=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/exception/NotValidDelegateUserException.kt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/main/kotlin/com/msg/gauth/domain/client/exception/NotValidDelegateUserException.kt diff --git a/src/main/kotlin/com/msg/gauth/domain/client/exception/NotValidDelegateUserException.kt b/src/main/kotlin/com/msg/gauth/domain/client/exception/NotValidDelegateUserException.kt new file mode 100644 index 00000000..3a9a1e13 --- /dev/null +++ b/src/main/kotlin/com/msg/gauth/domain/client/exception/NotValidDelegateUserException.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 NotValidDelegateUserException: BasicException(ErrorCode.BAD_REQUEST) \ No newline at end of file From 62aee4eb24508bf8eb1f61d28304424ca84326af Mon Sep 17 00:00:00 2001 From: Umjiseung <127853946+Umjiseung@users.noreply.github.com> Date: Wed, 6 Mar 2024 20:20:47 +0900 Subject: [PATCH 2/5] =?UTF-8?q?add=20::=20=EC=9E=AC=ED=95=99=EC=83=9D=20?= =?UTF-8?q?=EA=B2=80=EC=A6=9D=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../msg/gauth/domain/client/service/DelegateOwnerService.kt | 6 ++++++ 1 file changed, 6 insertions(+) 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..ee3dd935 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,11 @@ 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.NotValidDelegateUserException import com.msg.gauth.domain.client.exception.UserNotMatchException import com.msg.gauth.domain.client.repository.ClientRepository +import com.msg.gauth.domain.user.UserRole +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 +36,9 @@ class DelegateOwnerService( val delegateUser = userRepository.findByIdOrNull(delegateUserId) ?: throw UserNotFoundException() + if (delegateUser.userRole.any { it.userRoleType != UserRoleType.ROLE_STUDENT }) + throw NotValidDelegateUserException() + val updateClient = Client( id = client.id, clientId = client.clientId, From fab0e4788a06bfc0d08180eab5700817705d5bc8 Mon Sep 17 00:00:00 2001 From: Umjiseung <127853946+Umjiseung@users.noreply.github.com> Date: Fri, 8 Mar 2024 14:37:20 +0900 Subject: [PATCH 3/5] =?UTF-8?q?update=20::=20ErrorCode=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...DelegateUserException.kt => InvalidDelegateUserException.kt} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/kotlin/com/msg/gauth/domain/client/exception/{NotValidDelegateUserException.kt => InvalidDelegateUserException.kt} (65%) diff --git a/src/main/kotlin/com/msg/gauth/domain/client/exception/NotValidDelegateUserException.kt b/src/main/kotlin/com/msg/gauth/domain/client/exception/InvalidDelegateUserException.kt similarity index 65% rename from src/main/kotlin/com/msg/gauth/domain/client/exception/NotValidDelegateUserException.kt rename to src/main/kotlin/com/msg/gauth/domain/client/exception/InvalidDelegateUserException.kt index 3a9a1e13..711734bb 100644 --- a/src/main/kotlin/com/msg/gauth/domain/client/exception/NotValidDelegateUserException.kt +++ b/src/main/kotlin/com/msg/gauth/domain/client/exception/InvalidDelegateUserException.kt @@ -3,4 +3,4 @@ package com.msg.gauth.domain.client.exception import com.msg.gauth.global.exception.ErrorCode import com.msg.gauth.global.exception.exceptions.BasicException -class NotValidDelegateUserException: BasicException(ErrorCode.BAD_REQUEST) \ No newline at end of file +class InvalidDelegateUserException: BasicException(ErrorCode.INVALID_DELEGATE_USER) \ No newline at end of file From d4050df1554110e47066d37ce783a46217b3b02b Mon Sep 17 00:00:00 2001 From: Umjiseung <127853946+Umjiseung@users.noreply.github.com> Date: Fri, 8 Mar 2024 14:38:22 +0900 Subject: [PATCH 4/5] =?UTF-8?q?add=20::=20InvalidDelegateUser=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/com/msg/gauth/global/exception/ErrorCode.kt | 1 + 1 file changed, 1 insertion(+) 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), From e7d4bff403ad73ae27234fcc59f291659ea43e6e Mon Sep 17 00:00:00 2001 From: Umjiseung <127853946+Umjiseung@users.noreply.github.com> Date: Fri, 8 Mar 2024 14:42:06 +0900 Subject: [PATCH 5/5] =?UTF-8?q?update=20::=20=EC=98=88=EC=99=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../msg/gauth/domain/client/service/DelegateOwnerService.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 ee3dd935..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,10 +3,9 @@ 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.NotValidDelegateUserException +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.UserRole import com.msg.gauth.domain.user.enums.UserRoleType import com.msg.gauth.domain.user.exception.UserNotFoundException import com.msg.gauth.domain.user.repository.UserRepository @@ -37,7 +36,7 @@ class DelegateOwnerService( ?: throw UserNotFoundException() if (delegateUser.userRole.any { it.userRoleType != UserRoleType.ROLE_STUDENT }) - throw NotValidDelegateUserException() + throw InvalidDelegateUserException() val updateClient = Client( id = client.id,