Skip to content

Commit

Permalink
feat(auth, windows): verifyBeforeUpdateEmail() API support (#12825)
Browse files Browse the repository at this point in the history
  • Loading branch information
russellwheatley committed May 28, 2024
1 parent 5e76153 commit 111b1ad
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1244,10 +1244,26 @@ void FirebaseAuthPlugin::VerifyBeforeUpdateEmail(
const AuthPigeonFirebaseApp& app, const std::string& new_email,
const PigeonActionCodeSettings* action_code_settings,
std::function<void(std::optional<FlutterError> reply)> result) {
result(FlutterError(
"unimplemented",
"VerifyBeforeUpdateEmail is not available on this platform yet.",
nullptr));
firebase::auth::Auth* firebaseAuth = GetAuthFromPigeon(app);
firebase::auth::User user = firebaseAuth->current_user();

if (action_code_settings != nullptr) {
printf(
"Firebase C++ SDK does not support using `ActionCodeSettings` for "
"`verifyBeforeUpdateEmail()` API currently");
}

firebase::Future<void> future =
user.SendEmailVerificationBeforeUpdatingEmail(new_email.c_str());

future.OnCompletion(
[result, firebaseAuth](const firebase::Future<void>& completed_future) {
if (completed_future.error() == 0) {
result(std::nullopt);
} else {
result(FirebaseAuthPlugin::ParseError(completed_future));
}
});
}

void FirebaseAuthPlugin::RevokeTokenWithAuthorizationCode(
Expand Down
14 changes: 10 additions & 4 deletions packages/firebase_auth/firebase_auth/windows/messages.g.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4025,10 +4025,16 @@ void FirebaseAuthUserHostApi::SetUp(flutter::BinaryMessenger* binary_messenger,
const auto& new_email_arg =
std::get<std::string>(encodable_new_email_arg);
const auto& encodable_action_code_settings_arg = args.at(2);
const auto* action_code_settings_arg =
&(std::any_cast<const PigeonActionCodeSettings&>(
std::get<CustomEncodableValue>(
encodable_action_code_settings_arg)));
// IF CODE REGENERATED, PLEASE REINSERT THIS. IF ARG IS NULL, APP
// CRASHES
const PigeonActionCodeSettings* action_code_settings_arg =
nullptr;
if (!encodable_action_code_settings_arg.IsNull()) {
action_code_settings_arg =
&(std::any_cast<const PigeonActionCodeSettings&>(
std::get<CustomEncodableValue>(
encodable_action_code_settings_arg)));
}
api->VerifyBeforeUpdateEmail(
app_arg, new_email_arg, action_code_settings_arg,
[reply](std::optional<FlutterError>&& output) {
Expand Down

0 comments on commit 111b1ad

Please sign in to comment.