Skip to content

Commit 96e8a26

Browse files
committed
fix: 로그인 로직과 회원탈퇴 로직 분리
1 parent 061f365 commit 96e8a26

4 files changed

Lines changed: 24 additions & 6 deletions

File tree

DevLog/Infra/Service/SocialLogin/AppleAuthenticationService.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ final class AppleAuthenticationService: AuthenticationService {
102102
}
103103

104104
func deleteAuth(_ uid: String) async throws {
105+
guard let currentUser = Auth.auth().currentUser else {
106+
throw AuthError.notAuthenticated
107+
}
108+
105109
let token = try await refreshAppleAccessToken()
106110

107111
try await revokeAppleAccessToken(token: token)
@@ -110,8 +114,9 @@ final class AppleAuthenticationService: AuthenticationService {
110114

111115
_ = try await deleteFunction.call(["uid": uid])
112116

113-
try await signOut(uid)
114-
try await user?.delete()
117+
try await currentUser.delete()
118+
try await messaging.deleteToken()
119+
try Auth.auth().signOut()
115120
}
116121

117122
func link(uid: String, email: String) async throws {

DevLog/Infra/Service/SocialLogin/GithubAuthenticationService.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,19 @@ final class GithubAuthenticationService: NSObject, AuthenticationService {
8181
}
8282

8383
func deleteAuth(_ uid: String) async throws {
84+
guard let currentUser = Auth.auth().currentUser else {
85+
throw AuthError.notAuthenticated
86+
}
87+
8488
try await revokeAccessToken()
8589

8690
let deleteFunction = functions.httpsCallable("deleteUserFirestoreData")
8791

8892
_ = try await deleteFunction.call(["uid": uid])
8993

90-
try await signOut(uid)
91-
try await user?.delete()
94+
try await currentUser.delete()
95+
try await messaging.deleteToken()
96+
try Auth.auth().signOut()
9297
}
9398

9499
func link(uid: String, email: String) async throws {

DevLog/Infra/Service/SocialLogin/GoogleAuthenticationService.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,19 @@ final class GoogleAuthenticationService: AuthenticationService {
7878
}
7979

8080
func deleteAuth(_ uid: String) async throws {
81+
guard let currentUser = Auth.auth().currentUser else {
82+
throw AuthError.notAuthenticated
83+
}
84+
8185
let deleteFunction = functions.httpsCallable("deleteUserFirestoreData")
8286

8387
_ = try await deleteFunction.call(["uid": uid])
8488

85-
try await signOut(uid)
86-
try await Auth.auth().currentUser?.delete()
89+
try await currentUser.delete()
90+
GIDSignIn.sharedInstance.signOut()
91+
try await GIDSignIn.sharedInstance.disconnect()
92+
try await messaging.deleteToken()
93+
try Auth.auth().signOut()
8794
}
8895

8996
func link(uid: String, email: String) async throws {

DevLog/Presentation/ViewModel/SettingViewModel.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ final class SettingViewModel: Store {
108108
send(.setAlert(isPresented: false))
109109
send(.setLoading(true))
110110
try await deleteAuthuseCase.execute()
111+
sessionUseCase.execute(false)
111112
} catch {
112113
send(.setAlert(isPresented: true, type: .error))
113114
}

0 commit comments

Comments
 (0)