Skip to content

Commit 111b1ad

Browse files
feat(auth, windows): verifyBeforeUpdateEmail() API support (#12825)
1 parent 5e76153 commit 111b1ad

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

packages/firebase_auth/firebase_auth/windows/firebase_auth_plugin.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,10 +1244,26 @@ void FirebaseAuthPlugin::VerifyBeforeUpdateEmail(
12441244
const AuthPigeonFirebaseApp& app, const std::string& new_email,
12451245
const PigeonActionCodeSettings* action_code_settings,
12461246
std::function<void(std::optional<FlutterError> reply)> result) {
1247-
result(FlutterError(
1248-
"unimplemented",
1249-
"VerifyBeforeUpdateEmail is not available on this platform yet.",
1250-
nullptr));
1247+
firebase::auth::Auth* firebaseAuth = GetAuthFromPigeon(app);
1248+
firebase::auth::User user = firebaseAuth->current_user();
1249+
1250+
if (action_code_settings != nullptr) {
1251+
printf(
1252+
"Firebase C++ SDK does not support using `ActionCodeSettings` for "
1253+
"`verifyBeforeUpdateEmail()` API currently");
1254+
}
1255+
1256+
firebase::Future<void> future =
1257+
user.SendEmailVerificationBeforeUpdatingEmail(new_email.c_str());
1258+
1259+
future.OnCompletion(
1260+
[result, firebaseAuth](const firebase::Future<void>& completed_future) {
1261+
if (completed_future.error() == 0) {
1262+
result(std::nullopt);
1263+
} else {
1264+
result(FirebaseAuthPlugin::ParseError(completed_future));
1265+
}
1266+
});
12511267
}
12521268

12531269
void FirebaseAuthPlugin::RevokeTokenWithAuthorizationCode(

packages/firebase_auth/firebase_auth/windows/messages.g.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4025,10 +4025,16 @@ void FirebaseAuthUserHostApi::SetUp(flutter::BinaryMessenger* binary_messenger,
40254025
const auto& new_email_arg =
40264026
std::get<std::string>(encodable_new_email_arg);
40274027
const auto& encodable_action_code_settings_arg = args.at(2);
4028-
const auto* action_code_settings_arg =
4029-
&(std::any_cast<const PigeonActionCodeSettings&>(
4030-
std::get<CustomEncodableValue>(
4031-
encodable_action_code_settings_arg)));
4028+
// IF CODE REGENERATED, PLEASE REINSERT THIS. IF ARG IS NULL, APP
4029+
// CRASHES
4030+
const PigeonActionCodeSettings* action_code_settings_arg =
4031+
nullptr;
4032+
if (!encodable_action_code_settings_arg.IsNull()) {
4033+
action_code_settings_arg =
4034+
&(std::any_cast<const PigeonActionCodeSettings&>(
4035+
std::get<CustomEncodableValue>(
4036+
encodable_action_code_settings_arg)));
4037+
}
40324038
api->VerifyBeforeUpdateEmail(
40334039
app_arg, new_email_arg, action_code_settings_arg,
40344040
[reply](std::optional<FlutterError>&& output) {

0 commit comments

Comments
 (0)