Skip to content

Commit

Permalink
🗑 Fix account deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
benlmyers committed Mar 9, 2022
1 parent ffbc85c commit b69c9a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Sources/EasyFirebase/Services/Auth/EasyAuth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ public class EasyAuth: NSObject {

internal static let auth = Auth.auth()

// MARK: - Private Static Properties
internal static let listenerKey: EasyFirestore.ListenerKey = "EASY_USER_UPDATE"

private static let listenerKey: EasyFirestore.ListenerKey = "EASY_USER_UPDATE"
// MARK: - Private Static Properties

private static let googleSignInCredentialHandler: (AuthCredential?) -> Void = { credential in
guard let credential = credential else { return }
Expand Down
9 changes: 8 additions & 1 deletion Sources/EasyFirebase/Services/Auth/EasyUser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,16 @@ public extension EasyUser {
func delete<T>(ofUserType type: T.Type, completion: @escaping (Error?) -> Void = { _ in }) where T: EasyUser {
guard assertAuthMatches() else { return }
if let authUser = authUser {
EasyFirestore.Listening.stop(EasyAuth.listenerKey)
authUser.delete { error in
completion(error)
if let error = error {
completion(error)
return
}
EasyFirestore.Removal.remove(id: self.id, ofType: T.self, completion: completion)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
EasyAuth.signOut()
}
}
}
}
Expand Down

0 comments on commit b69c9a5

Please sign in to comment.