Skip to content
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

implement User.delete #68

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions Sources/FirebaseAuth/FirebaseUser+Swift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,33 @@ public final class User {
// }

public func delete(completion: ((Error?) -> Void)?) {
fatalError("\(#function) not yet implemented")
deleteImpl() { error in
if let completion {
DispatchQueue.main.async {
completion(error)
}
}
}
}

public func delete() async throws {
fatalError("\(#function) not yet implemented")
try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, any Error>) in
deleteImpl() { error in
if let error {
continuation.resume(throwing: error)
} else {
continuation.resume()
}
}
}
}

private func deleteImpl(completion: @escaping (Error?) -> Void) {
let future = swift_firebase.swift_cxx_shims.firebase.auth.user_delete(impl)
future.setCompletion({
let (_, error) = future.resultAndError { AuthErrorCode($0) }
completion(error)
})
}

public func sendEmailVerification(beforeUpdatingEmail email: String) async throws {
Expand Down
6 changes: 6 additions & 0 deletions Sources/firebase/include/FirebaseAuth.hh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ user_reload(::firebase::auth::User user) {
user.Reload());
}

inline ::swift_firebase::swift_cxx_shims::firebase::VoidFuture
user_delete(::firebase::auth::User user) {
return ::swift_firebase::swift_cxx_shims::firebase::VoidFuture::From(
user.Delete());
}

inline ::swift_firebase::swift_cxx_shims::firebase::Future<
::firebase::auth::AuthResult>
user_reauthenticate_and_retrieve_data(
Expand Down
Loading