-
Notifications
You must be signed in to change notification settings - Fork 0
[#251] 여러 계정을 링크한 이후 각 공급자에 대한 실질적인 회원탈퇴가 이루어지지 않는 이슈를 해결한다 #252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
5d155e2
81f0c99
77fbb23
21a6518
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,17 +7,21 @@ | |
|
|
||
| import FirebaseAuth | ||
| import FirebaseFirestore | ||
| import FirebaseFunctions | ||
| import FirebaseMessaging | ||
|
|
||
| final class AuthService { | ||
| private let store = Firestore.firestore() | ||
| private let functions = Functions.functions(region: "asia-northeast3") | ||
| private let messaging = Messaging.messaging() | ||
| private let logger = Logger(category: "AuthService") | ||
|
|
||
| var uid: String? { | ||
| Auth.auth().currentUser?.uid | ||
| } | ||
|
|
||
| var providerIDs: [String]? { | ||
| Auth.auth().currentUser?.providerData.map { $0.providerID } | ||
| var providerIDs: [String] { | ||
| Auth.auth().currentUser?.providerData.map { $0.providerID } ?? [] | ||
| } | ||
|
|
||
| func getProviderID() async throws -> String? { | ||
|
|
@@ -42,4 +46,29 @@ final class AuthService { | |
| throw error | ||
| } | ||
| } | ||
|
|
||
| func deleteFirestoreUserData(_ uid: String) async throws { | ||
| logger.info("Deleting Firestore user data. uid: \(uid)") | ||
|
|
||
| let deleteFunction = functions.httpsCallable("deleteUserFirestoreData") | ||
| _ = try await deleteFunction.call(["uid": uid]) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| } | ||
|
|
||
| func deleteCurrentUser() async throws { | ||
| logger.info("Deleting FirebaseAuth current user") | ||
|
|
||
| guard let currentUser = Auth.auth().currentUser else { | ||
| logger.warning("No current user to delete") | ||
| throw AuthError.notAuthenticated | ||
| } | ||
|
|
||
| try await currentUser.delete() | ||
| } | ||
|
|
||
| func clearCurrentSession() async throws { | ||
| logger.info("Clearing current auth session") | ||
|
|
||
| try await messaging.deleteToken() | ||
| try Auth.auth().signOut() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
do {
try await messaging.deleteToken()
} catch {
logger.error("Failed to delete FCM token during session clearing", error: error)
}
try Auth.auth().signOut() |
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
현재
delete메서드는 연결된 모든 제공자를 반복하며deleteAuth를 호출합니다. 이 호출 중 하나라도 실패하면 (예: 네트워크 오류 또는 만료된 세션으로 인해) 전체 삭제 프로세스가 중단됩니다. 이로 인해 계정이 부분적으로만 삭제된 상태로 남게 됩니다. 일부 제공자(예: Apple)는deleteAuth중에 토큰을 해지하므로, 계정을 다시 삭제하려는 시도는 해지된 제공자가 이제 일관되게 오류를 반환하기 때문에 영구적으로 실패할 수 있습니다. 이는 사용자가 계정과 Firestore 데이터를 완전히 삭제할 수 없게 만드는 로직 결함으로 이어질 수 있습니다.TaskGroup을 사용하여 각 프로바이더의 인증 해제 작업을 병렬로 실행하고, 개별 작업의 실패가 다른 작업에 영향을 주지 않도록 하는 것이 더 안정적입니다. 이렇게 하면 모든 프로바이더에 대한 해지를 시도하고, 일부가 실패하더라도 최종적인 사용자 삭제는 계속 진행할 수 있으며, 탈퇴 과정의 속도도 개선될 수 있습니다.