Skip to content

Commit 94a5dc0

Browse files
authored
[#619] FCM Token을 해제하지 못할 시 로그아웃에 실패하는 현상을 해결한다 (#622)
1 parent 5fd6fe6 commit 94a5dc0

21 files changed

Lines changed: 104 additions & 83 deletions

Application/DevLogData/Sources/Common/DataLayerError.swift

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// Created by opfic on 3/11/26.
66
//
77

8-
import AuthenticationServices
98
import Foundation
109
import DevLogCore
1110

@@ -48,17 +47,3 @@ public enum DataLayerError: Error {
4847
case notAuthenticated
4948
case linkCredentialAlreadyInUse
5049
}
51-
52-
public extension Error {
53-
var isSocialLoginCancelled: Bool {
54-
switch self {
55-
case let authError as ASAuthorizationError:
56-
return authError.code == .canceled
57-
case let webAuthError as ASWebAuthenticationSessionError:
58-
return webAuthError.code == .canceledLogin
59-
default:
60-
let nsError = self as NSError
61-
return nsError.domain == "com.google.GIDSignIn" && nsError.code == -5
62-
}
63-
}
64-
}

Application/DevLogData/Sources/Protocol/AuthenticationService.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import Foundation
99

1010
public protocol AuthenticationService {
11-
func signIn() async throws -> AuthDataResponse
11+
func signIn() async throws -> AuthDataResponse?
1212
func signOut(_ uid: String) async throws
1313
func deleteAuth(_ uid: String) async throws
14-
func link(uid: String, email: String) async throws
14+
func link(uid: String, email: String) async throws -> Bool
1515
func unlink(_ uid: String) async throws
1616
}

Application/DevLogData/Sources/Repository/AuthDataRepositoryImpl.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ final class AuthDataRepositoryImpl: AuthDataRepository {
3737
return providerStrings.compactMap { AuthProvider(rawValue: $0) }
3838
}
3939

40-
func linkProvider(_ provider: AuthProvider) async throws {
40+
func linkProvider(_ provider: AuthProvider) async throws -> Bool {
4141
guard let uid = authService.uid,
4242
let email = authService.currentUserEmail else {
4343
throw AuthError.notAuthenticated
@@ -54,7 +54,7 @@ final class AuthDataRepositoryImpl: AuthDataRepository {
5454
}
5555

5656
do {
57-
try await service.link(uid: uid, email: email)
57+
return try await service.link(uid: uid, email: email)
5858
} catch {
5959
throw mapLinkError(error)
6060
}

Application/DevLogData/Sources/Repository/AuthenticationRepositoryImpl.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ final class AuthenticationRepositoryImpl: AuthenticationRepository {
3131
self.widgetSnapshotUpdater = widgetSnapshotUpdater
3232
}
3333

34-
func signIn(_ provider: AuthProvider) async throws {
34+
func signIn(_ provider: AuthProvider) async throws -> Bool {
3535
authService.beginSignIn()
3636

3737
do {
38-
let response: AuthDataResponse
38+
let response: AuthDataResponse?
3939
switch provider {
4040
case .apple:
4141
response = try await appleAuthService.signIn()
@@ -45,8 +45,14 @@ final class AuthenticationRepositoryImpl: AuthenticationRepository {
4545
response = try await googleAuthService.signIn()
4646
}
4747

48+
guard let response else {
49+
authService.cancelSignIn()
50+
return false
51+
}
52+
4853
try await userService.upsertUser(response)
4954
authService.completeSignIn()
55+
return true
5056
} catch {
5157
if authService.uid != nil {
5258
try? await authService.clearCurrentSession()

Application/DevLogDomain/Sources/Protocol/AuthDataRepository.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public protocol AuthDataRepository {
1313
func fetchAllProviders() async throws -> [AuthProvider]
1414

1515
/// 특정 프로바이더를 계정에 연결합니다
16-
func linkProvider(_ provider: AuthProvider) async throws
16+
func linkProvider(_ provider: AuthProvider) async throws -> Bool
1717

1818
/// 특정 프로바이더를 계정에서 해제합니다
1919
func unlinkProvider(_ provider: AuthProvider) async throws

Application/DevLogDomain/Sources/Protocol/AuthenticationRepository.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99

1010
public protocol AuthenticationRepository {
11-
func signIn(_ provider: AuthProvider) async throws
11+
func signIn(_ provider: AuthProvider) async throws -> Bool
1212
func signOut() async throws
1313
func restore() -> Bool
1414
func delete() async throws

Application/DevLogDomain/Sources/UseCase/Auth/Provider/LinkAuthProviderUseCase.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
//
77

88
public protocol LinkAuthProviderUseCase {
9-
func execute(_ provider: AuthProvider) async throws
9+
func execute(_ provider: AuthProvider) async throws -> Bool
1010
}

Application/DevLogDomain/Sources/UseCase/Auth/Provider/LinkAuthProviderUseCaseImpl.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public final class LinkAuthProviderUseCaseImpl: LinkAuthProviderUseCase {
1212
self.repository = repository
1313
}
1414

15-
public func execute(_ provider: AuthProvider) async throws {
15+
public func execute(_ provider: AuthProvider) async throws -> Bool {
1616
try await repository.linkProvider(provider)
1717
}
1818
}

Application/DevLogDomain/Sources/UseCase/Auth/SignIn/SignInUseCase.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
//
77

88
public protocol SignInUseCase {
9-
func execute(_ provider: AuthProvider) async throws
9+
func execute(_ provider: AuthProvider) async throws -> Bool
1010
}

Application/DevLogDomain/Sources/UseCase/Auth/SignIn/SignInUseCaseImpl.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public final class SignInUseCaseImpl: SignInUseCase {
1212
self.repository = repository
1313
}
1414

15-
public func execute(_ provider: AuthProvider) async throws {
15+
public func execute(_ provider: AuthProvider) async throws -> Bool {
1616
try await repository.signIn(provider)
1717
}
1818
}

0 commit comments

Comments
 (0)