From 82d880bf3ec59b5ddd7cf253f4e68aa8bf5d3d26 Mon Sep 17 00:00:00 2001 From: opficdev Date: Wed, 11 Mar 2026 10:09:09 +0900 Subject: [PATCH 1/4] =?UTF-8?q?chore:=20=EC=97=90=EB=9F=AC=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=EC=9D=84=20=EB=A0=88=EC=9D=B4=EC=96=B4=EC=97=90=20?= =?UTF-8?q?=EB=94=B0=EB=9D=BC=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{Error+.swift => DataLayerError.swift} | 19 ++----------- DevLog/Infra/Common/InfraLayerError.swift | 28 +++++++++++++++++++ DevLog/Infra/{Util => Common}/Logger.swift | 0 .../TopViewControllerProvider.swift | 0 .../Service/SocialLogin/EmailFetchError.swift | 13 --------- 5 files changed, 30 insertions(+), 30 deletions(-) rename DevLog/Data/Common/{Error+.swift => DataLayerError.swift} (63%) create mode 100644 DevLog/Infra/Common/InfraLayerError.swift rename DevLog/Infra/{Util => Common}/Logger.swift (100%) rename DevLog/Infra/{Util => Common}/TopViewControllerProvider.swift (100%) delete mode 100644 DevLog/Infra/Service/SocialLogin/EmailFetchError.swift diff --git a/DevLog/Data/Common/Error+.swift b/DevLog/Data/Common/DataLayerError.swift similarity index 63% rename from DevLog/Data/Common/Error+.swift rename to DevLog/Data/Common/DataLayerError.swift index cda9fc17..c12d40d0 100644 --- a/DevLog/Data/Common/Error+.swift +++ b/DevLog/Data/Common/DataLayerError.swift @@ -1,8 +1,8 @@ // -// Error+.swift +// DataLayerError.swift // DevLog // -// Created by 최윤진 on 11/29/25. +// Created by opfic on 3/11/26. // import Foundation @@ -13,21 +13,6 @@ enum AuthError: Error { case unsupportedProvider } -enum FirestoreError: Error, LocalizedError { - case dataNotFound(_ key: String) - - var errorDescription: String? { - switch self { - case .dataNotFound(let key): - return "\(key)가 Firestore에서 존재하지 않음" - } - } -} - -enum UIError: Error { - case notFoundTopViewController -} - enum DataError: Error { case invalidData(context: String) diff --git a/DevLog/Infra/Common/InfraLayerError.swift b/DevLog/Infra/Common/InfraLayerError.swift new file mode 100644 index 00000000..358cef5d --- /dev/null +++ b/DevLog/Infra/Common/InfraLayerError.swift @@ -0,0 +1,28 @@ +// +// InfraLayerError.swift +// DevLog +// +// Created by opfic on 3/11/26. +// + +import Foundation + +enum FirestoreError: Error, LocalizedError { + case dataNotFound(_ key: String) + + var errorDescription: String? { + switch self { + case .dataNotFound(let key): + return "\(key)가 Firestore에서 존재하지 않음" + } + } +} + +enum UIError: Error { + case notFoundTopViewController +} + +enum EmailFetchError: Error, Equatable { + case emailNotFound + case emailMismatch +} diff --git a/DevLog/Infra/Util/Logger.swift b/DevLog/Infra/Common/Logger.swift similarity index 100% rename from DevLog/Infra/Util/Logger.swift rename to DevLog/Infra/Common/Logger.swift diff --git a/DevLog/Infra/Util/TopViewControllerProvider.swift b/DevLog/Infra/Common/TopViewControllerProvider.swift similarity index 100% rename from DevLog/Infra/Util/TopViewControllerProvider.swift rename to DevLog/Infra/Common/TopViewControllerProvider.swift diff --git a/DevLog/Infra/Service/SocialLogin/EmailFetchError.swift b/DevLog/Infra/Service/SocialLogin/EmailFetchError.swift deleted file mode 100644 index 5923aacc..00000000 --- a/DevLog/Infra/Service/SocialLogin/EmailFetchError.swift +++ /dev/null @@ -1,13 +0,0 @@ -// -// EmailFetchError.swift -// DevLog -// -// Created by 최윤진 on 11/2/25. -// - -import Foundation - -enum EmailFetchError: Error, Equatable { - case emailNotFound - case emailMismatch -} From 64f628037636006dcb21e526842b2ea4e5fa8fb3 Mon Sep 17 00:00:00 2001 From: opficdev Date: Wed, 11 Mar 2026 10:30:30 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=EC=97=90=EB=9F=AC=EA=B0=80=20?= =?UTF-8?q?=EC=9C=A0=EC=A0=80=EA=B0=80=20=EB=A1=9C=EA=B7=B8=EC=9D=B8?= =?UTF-8?q?=EC=9D=84=20=EC=B7=A8=EC=86=8C=ED=95=98=EB=A9=B4=20=EC=96=BC?= =?UTF-8?q?=EB=9F=BF=EC=9D=84=20=EB=9D=84=EC=9A=B0=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DevLog/Presentation/ViewModel/LoginViewModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DevLog/Presentation/ViewModel/LoginViewModel.swift b/DevLog/Presentation/ViewModel/LoginViewModel.swift index 7f192bda..a1fd81c8 100644 --- a/DevLog/Presentation/ViewModel/LoginViewModel.swift +++ b/DevLog/Presentation/ViewModel/LoginViewModel.swift @@ -8,7 +8,6 @@ import Combine import Foundation import FirebaseAuth -import GoogleSignIn @Observable final class LoginViewModel: Store { @@ -93,6 +92,7 @@ final class LoginViewModel: Store { } catch { send(.setLogined(false)) sessionUseCase.execute(false) + if error.isSocialLoginCancelled { return } send(.setAlert(true)) } } From 4f8f6d49782ce54b6844dbba9d7b362104d94fd1 Mon Sep 17 00:00:00 2001 From: opficdev Date: Wed, 11 Mar 2026 10:32:23 +0900 Subject: [PATCH 3/4] =?UTF-8?q?refactor:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EB=8F=84=EB=A9=94=EC=9D=B8=EC=97=90=20=EB=94=B0=EB=9D=BC=20?= =?UTF-8?q?=EB=B6=84=EA=B8=B0=20=EB=B0=8F=20=EC=BB=A4=EC=8A=A4=ED=85=80=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DevLog/Infra/Common/InfraLayerError.swift | 26 +++++++++++++++++++ .../GithubAuthenticationService.swift | 4 +-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/DevLog/Infra/Common/InfraLayerError.swift b/DevLog/Infra/Common/InfraLayerError.swift index 358cef5d..e283ff92 100644 --- a/DevLog/Infra/Common/InfraLayerError.swift +++ b/DevLog/Infra/Common/InfraLayerError.swift @@ -5,7 +5,9 @@ // Created by opfic on 3/11/26. // +import AuthenticationServices import Foundation +import GoogleSignIn enum FirestoreError: Error, LocalizedError { case dataNotFound(_ key: String) @@ -26,3 +28,27 @@ enum EmailFetchError: Error, Equatable { case emailNotFound case emailMismatch } + +enum SocialLoginError: Error { + case invalidOAuthState + case failedToStartWebAuthenticationSession +} + +extension Error { + var isSocialLoginCancelled: Bool { + // Apple 로그인 취소 + if let authorizationError = self as? ASAuthorizationError { + return authorizationError.code == .canceled + } + + // Github 로그인 취소 + if let webAuthenticationSessionError = self as? ASWebAuthenticationSessionError { + return webAuthenticationSessionError.code == .canceledLogin + } + + let error = self as NSError + // Google 로그인 취소 + return error.domain == kGIDSignInErrorDomain + && error.code == GIDSignInError.canceled.rawValue + } +} diff --git a/DevLog/Infra/Service/SocialLogin/GithubAuthenticationService.swift b/DevLog/Infra/Service/SocialLogin/GithubAuthenticationService.swift index 1e5d94c4..81c7a342 100644 --- a/DevLog/Infra/Service/SocialLogin/GithubAuthenticationService.swift +++ b/DevLog/Infra/Service/SocialLogin/GithubAuthenticationService.swift @@ -187,7 +187,7 @@ final class GithubAuthenticationService: NSObject, AuthenticationService { // 반환된 state 값 확인 / 받아온 값이 다르면 CSRF 공격 가능성 있음 guard let returnedState = queryItems.first(where: { $0.name == "state" })?.value, returnedState == state else { - continuation.resume(throwing: URLError(.userCancelledAuthentication)) + continuation.resume(throwing: SocialLoginError.invalidOAuthState) return } @@ -198,7 +198,7 @@ final class GithubAuthenticationService: NSObject, AuthenticationService { session.prefersEphemeralWebBrowserSession = false // 웹에서 깃헙 로그인 후 세션 유지 if !session.start() { - continuation.resume(throwing: URLError(.userCancelledAuthentication)) + continuation.resume(throwing: SocialLoginError.failedToStartWebAuthenticationSession) } } } From 2da8ce66858cbae3e79b3616665147d57786485e Mon Sep 17 00:00:00 2001 From: opficdev Date: Wed, 11 Mar 2026 10:39:22 +0900 Subject: [PATCH 4/4] =?UTF-8?q?refactor:=20case=EB=AC=B8=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DevLog/Infra/Common/InfraLayerError.swift | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/DevLog/Infra/Common/InfraLayerError.swift b/DevLog/Infra/Common/InfraLayerError.swift index e283ff92..4bbd9c67 100644 --- a/DevLog/Infra/Common/InfraLayerError.swift +++ b/DevLog/Infra/Common/InfraLayerError.swift @@ -36,19 +36,17 @@ enum SocialLoginError: Error { extension Error { var isSocialLoginCancelled: Bool { + switch self { // Apple 로그인 취소 - if let authorizationError = self as? ASAuthorizationError { - return authorizationError.code == .canceled - } - + case let authError as ASAuthorizationError: + return authError.code == .canceled // Github 로그인 취소 - if let webAuthenticationSessionError = self as? ASWebAuthenticationSessionError { - return webAuthenticationSessionError.code == .canceledLogin + case let webAuthError as ASWebAuthenticationSessionError: + return webAuthError.code == .canceledLogin + default: + let nsError = self as NSError + // Google 로그인 취소 + return nsError.domain == kGIDSignInErrorDomain && nsError.code == GIDSignInError.canceled.rawValue } - - let error = self as NSError - // Google 로그인 취소 - return error.domain == kGIDSignInErrorDomain - && error.code == GIDSignInError.canceled.rawValue } }