diff --git a/auth/integration_test/src/integration_test.cc b/auth/integration_test/src/integration_test.cc index eef1301adc..39be99752a 100644 --- a/auth/integration_test/src/integration_test.cc +++ b/auth/integration_test/src/integration_test.cc @@ -580,11 +580,6 @@ TEST_F(FirebaseAuthTest, TestOperationsOnInvalidUser) { WaitForCompletionOrInvalidStatus(string_future, "GetToken"); EXPECT_NE(string_future.error(), firebase::auth::kAuthErrorNone); - LogDebug("Update Email"); - void_future = invalid_user.UpdateEmail(GenerateEmailAddress().c_str()); - WaitForCompletionOrInvalidStatus(void_future, "UpdateEmail"); - EXPECT_NE(void_future.error(), firebase::auth::kAuthErrorNone); - LogDebug("Update Password"); void_future = invalid_user.UpdatePassword(kTestPassword); WaitForCompletionOrInvalidStatus(void_future, "UpdatePassword"); @@ -758,30 +753,6 @@ TEST_F(FirebaseAuthTest, TestUpdateUserProfileEmpty) { DeleteUser(); } -TEST_F(FirebaseAuthTest, TestUpdateEmailAndPassword) { - std::string email = GenerateEmailAddress(); - WaitForCompletion( - auth_->CreateUserWithEmailAndPassword(email.c_str(), kTestPassword), - "CreateUserWithEmailAndPassword"); - firebase::auth::User user = auth_->current_user(); - EXPECT_TRUE(user.is_valid()); - - // Update the user's email and password. - const std::string new_email = "new_" + email; - WaitForCompletion(user.UpdateEmail(new_email.c_str()), "UpdateEmail"); - WaitForCompletion(user.UpdatePassword(kTestPasswordUpdated), - "UpdatePassword"); - - firebase::auth::Credential new_email_cred = - firebase::auth::EmailAuthProvider::GetCredential(new_email.c_str(), - kTestPasswordUpdated); - WaitForCompletion(user.Reauthenticate(new_email_cred), "Reauthenticate"); - EXPECT_TRUE(user.is_valid()); - - WaitForCompletion(user.SendEmailVerification(), "SendEmailVerification"); - DeleteUser(); -} - TEST_F(FirebaseAuthTest, TestVerifyBeforeUpdatingEmail) { std::string email = GenerateEmailAddress(); WaitForCompletion( diff --git a/auth/samples/src/doc_samples.cc b/auth/samples/src/doc_samples.cc index 143393390b..7ff846f50e 100644 --- a/auth/samples/src/doc_samples.cc +++ b/auth/samples/src/doc_samples.cc @@ -360,23 +360,6 @@ void VariousUserManagementChecks(firebase::auth::Auth* auth) { } // [END auth_profile_edit_check] } - { - // [START auth_set_email_check] - firebase::auth::User user = auth->current_user(); - if (user.is_valid()) { - user.UpdateEmail("user@example.com") - .OnCompletion( - [](const firebase::Future& completed_future, - void* user_data) { - // We are probably in a different thread right now. - if (completed_future.error() == 0) { - printf("User email address updated."); - } - }, - nullptr); - } - // [END auth_set_email_check] - } { // [START auth_user_verify_email_check] firebase::auth::User user = auth->current_user(); diff --git a/auth/src/android/user_android.cc b/auth/src/android/user_android.cc index 4e638a85db..62a9d1d936 100644 --- a/auth/src/android/user_android.cc +++ b/auth/src/android/user_android.cc @@ -41,8 +41,6 @@ METHOD_LOOKUP_DEFINITION(tokenresult, X(IsAnonymous, "isAnonymous", "()Z"), \ X(Token, "getIdToken", "(Z)Lcom/google/android/gms/tasks/Task;"), \ X(ProviderData, "getProviderData", "()Ljava/util/List;"), \ - X(UpdateEmail, "updateEmail", "(Ljava/lang/String;)" \ - "Lcom/google/android/gms/tasks/Task;"), \ X(VerifyBeforeUpdateEmail, "verifyBeforeUpdateEmail", \ "(Ljava/lang/String;)Lcom/google/android/gms/tasks/Task;"), \ X(UpdatePassword, "updatePassword", "(Ljava/lang/String;)" \ @@ -353,26 +351,6 @@ std::vector User::provider_data() const { return provider_data; } -Future User::UpdateEmail(const char* email) { - if (!ValidUser(auth_data_)) { - return Future(); - } - ReferenceCountedFutureImpl& futures = auth_data_->future_impl; - const auto handle = futures.SafeAlloc(kUserFn_UpdateEmail); - JNIEnv* env = Env(auth_data_); - - jstring j_email = env->NewStringUTF(email); - jobject pending_result = env->CallObjectMethod( - UserImpl(auth_data_), user::GetMethodId(user::kUpdateEmail), j_email); - env->DeleteLocalRef(j_email); - - if (!CheckAndCompleteFutureOnError(env, &futures, handle)) { - RegisterCallback(pending_result, handle, auth_data_, nullptr); - env->DeleteLocalRef(pending_result); - } - return MakeFuture(&futures, handle); -} - Future User::UpdatePassword(const char* password) { if (!ValidUser(auth_data_)) { return Future(); diff --git a/auth/src/desktop/rpcs/set_account_info_request.cc b/auth/src/desktop/rpcs/set_account_info_request.cc index 618cbef902..4a9a961e3d 100644 --- a/auth/src/desktop/rpcs/set_account_info_request.cc +++ b/auth/src/desktop/rpcs/set_account_info_request.cc @@ -36,20 +36,6 @@ SetAccountInfoRequest::SetAccountInfoRequest(::firebase::App& app, application_data_->returnSecureToken = true; } -std::unique_ptr -SetAccountInfoRequest::CreateUpdateEmailRequest(::firebase::App& app, - const char* const api_key, - const char* const email) { - auto request = CreateRequest(app, api_key); - if (email) { - request->application_data_->email = email; - } else { - LogError("No email given"); - } - request->UpdatePostFields(); - return request; -} - std::unique_ptr SetAccountInfoRequest::CreateUpdatePasswordRequest( ::firebase::App& app, const char* const api_key, const char* const password, diff --git a/auth/src/desktop/rpcs/set_account_info_request.h b/auth/src/desktop/rpcs/set_account_info_request.h index a96f5b595e..3c72a13e2b 100644 --- a/auth/src/desktop/rpcs/set_account_info_request.h +++ b/auth/src/desktop/rpcs/set_account_info_request.h @@ -31,8 +31,6 @@ namespace auth { class SetAccountInfoRequest : public AuthRequest { public: - static std::unique_ptr CreateUpdateEmailRequest( - ::firebase::App& app, const char* api_key, const char* email); static std::unique_ptr CreateUpdatePasswordRequest( ::firebase::App& app, const char* api_key, const char* password, const char* language_code = nullptr); diff --git a/auth/src/desktop/user_desktop.cc b/auth/src/desktop/user_desktop.cc index 6d8d0b5fd6..fb065e9f27 100644 --- a/auth/src/desktop/user_desktop.cc +++ b/auth/src/desktop/user_desktop.cc @@ -835,34 +835,6 @@ Future User::Reload() { callback); } -Future User::UpdateEmail(const char* const email) { - if (auth_data_ == nullptr) { // user is not valid - return Future(); // invalid future - } - Promise promise(&auth_data_->future_impl, kUserFn_UpdateEmail); - if (!ValidateCurrentUser(&promise, auth_data_)) { - return promise.LastResult(); - } - if (!ValidateEmail(&promise, email)) { - return promise.LastResult(); - } - if (!ValidateCurrentUser(&promise, auth_data_)) { - return promise.LastResult(); - } - - const char* language_code = nullptr; - auto auth_impl = static_cast(auth_data_->auth_impl); - if (!auth_impl->language_code.empty()) { - language_code = auth_impl->language_code.c_str(); - } - - typedef SetAccountInfoRequest RequestT; - auto request = RequestT::CreateUpdateEmailRequest( - *auth_data_->app, GetApiKey(*auth_data_), email); - return CallAsyncWithFreshToken(auth_data_, promise, std::move(request), - PerformSetAccountInfoFlow); -} - Future User::UpdatePassword(const char* const password) { if (auth_data_ == nullptr) { // user is not valid return Future(); // invalid future diff --git a/auth/src/include/firebase/auth/user.h b/auth/src/include/firebase/auth/user.h index 8e044e62e5..c58801cf26 100644 --- a/auth/src/include/firebase/auth/user.h +++ b/auth/src/include/firebase/auth/user.h @@ -229,20 +229,6 @@ class User : public UserInfoInterface { /// std::vector provider_data() const; - /// @deprecated This is a deprecated method. Please use - /// SendEmailVerificationBeforeUpdatingEmail(email) instead. - /// - /// Sets the email address for the user. - /// - /// May fail if there is already an email/password-based account for the same - /// email address. - FIREBASE_DEPRECATED Future UpdateEmail(const char* email); - - /// @deprecated - /// - /// Get results of the most recent call to UpdateEmail. - FIREBASE_DEPRECATED Future UpdateEmailLastResult() const; - /// Attempts to change the password for the current user. /// /// For an account linked to an Identity Provider (IDP) with no password, diff --git a/auth/src/ios/user_ios.mm b/auth/src/ios/user_ios.mm index f05bb23b14..2eb020307f 100644 --- a/auth/src/ios/user_ios.mm +++ b/auth/src/ios/user_ios.mm @@ -102,20 +102,6 @@ explicit IOSWrappedUserInfo(id user_info) : user_info_(user_info) { return provider_data; } -Future User::UpdateEmail(const char *email) { - if (!ValidUser(auth_data_)) { - return Future(); - } - ReferenceCountedFutureImpl &futures = auth_data_->future_impl; - const auto handle = futures.SafeAlloc(kUserFn_UpdateEmail); - [UserImpl(auth_data_) updateEmail:@(email) - completion:^(NSError *_Nullable error) { - futures.Complete(handle, AuthErrorFromNSError(error), - [error.localizedDescription UTF8String]); - }]; - return MakeFuture(&futures, handle); -} - Future User::UpdatePassword(const char *password) { if (!ValidUser(auth_data_)) { return Future(); diff --git a/auth/src/user.cc b/auth/src/user.cc index a271f008aa..4f48f6d7f0 100644 --- a/auth/src/user.cc +++ b/auth/src/user.cc @@ -20,7 +20,6 @@ namespace firebase { namespace auth { AUTH_RESULT_FN(User, GetToken, std::string) -AUTH_RESULT_FN(User, UpdateEmail, void) AUTH_RESULT_FN(User, UpdatePassword, void) AUTH_RESULT_FN(User, LinkWithCredential, AuthResult) AUTH_RESULT_FN(User, Reauthenticate, void) diff --git a/auth/tests/desktop/user_desktop_test.cc b/auth/tests/desktop/user_desktop_test.cc index 567380165a..276bf3221c 100644 --- a/auth/tests/desktop/user_desktop_test.cc +++ b/auth/tests/desktop/user_desktop_test.cc @@ -436,23 +436,6 @@ TEST_F(UserDesktopTest, TestReload) { VerifyProviderData(firebase_user_); } -// Tests the happy case of setting a new email on the currently logged in user. -TEST_F(UserDesktopTest, TestUpdateEmail) { - InitializeConfigWithAFake(GetUrlForApi(API_KEY, "setAccountInfo"), - FakeSetAccountInfoResponse()); - - // SetAccountInfoResponse contains a new token. - id_token_listener.ExpectChanges(1); - auth_state_listener.ExpectChanges(0); - - const std::string new_email = "new_fake_email@example.com"; - - EXPECT_NE(new_email, firebase_user_.email()); - WaitForFuture(firebase_user_.UpdateEmail(new_email.c_str())); - EXPECT_EQ(new_email, firebase_user_.email()); - VerifyProviderData(firebase_user_); -} - // Tests the happy case of setting a new password on the currently logged in // user. TEST_F(UserDesktopTest, TestUpdatePassword) { @@ -815,16 +798,6 @@ TEST_F(UserDesktopTestSignOutOnError, Reload) { sem_.Wait(); } -TEST_F(UserDesktopTestSignOutOnError, UpdateEmail) { - CheckSignOutIfUserIsInvalid( - GetUrlForApi(API_KEY, "setAccountInfo"), "USER_NOT_FOUND", - kAuthErrorUserNotFound, [&] { - sem_.Post(); - return firebase_user_.UpdateEmail("fake_email@example.com"); - }); - sem_.Wait(); -} - TEST_F(UserDesktopTestSignOutOnError, UpdatePassword) { CheckSignOutIfUserIsInvalid( GetUrlForApi(API_KEY, "setAccountInfo"), "USER_DISABLED", @@ -881,30 +854,6 @@ TEST_F(UserDesktopTestSignOutOnError, GetToken) { sem_.Wait(); } -// This test is to expose potential race condition and is primarily intended to -// be run with --config=tsan -TEST_F(UserDesktopTest, TestRaceCondition_SetAccountInfoAndSignOut) { - InitializeConfigWithAFake(GetUrlForApi(API_KEY, "setAccountInfo"), - FakeSetAccountInfoResponse()); - - // SignOut is engaged on the main thread, whereas UpdateEmail will be executed - // on the background thread; consequently, the order in which they are - // executed is not defined. Nevertheless, this should not lead to any data - // corruption, when UpdateEmail writes to user profile while it's being - // deleted by SignOut. Whichever method succeeds first, user must be signed - // out once both are finished: if SignOut finishes last, it overrides the - // updated user, and if UpdateEmail finishes last, it should note that there - // is no currently signed in user and fail with kAuthErrorUserNotFound. - - auto future = firebase_user_.UpdateEmail("some_email"); - firebase_auth_->SignOut(); - while (future.status() == firebase::kFutureStatusPending) { - } - - EXPECT_THAT(future.error(), AnyOf(kAuthErrorNone, kAuthErrorNoSignedInUser)); - EXPECT_FALSE(firebase_auth_->current_user().is_valid()); -} - // LinkWithProvider tests. TEST_F(UserDesktopTest, TestLinkWithProviderReturnsUnsupportedError) { FederatedOAuthProvider provider; diff --git a/auth/tests/user_test.cc b/auth/tests/user_test.cc index 125ec8dbd8..79ed0d933e 100644 --- a/auth/tests/user_test.cc +++ b/auth/tests/user_test.cc @@ -258,36 +258,6 @@ TEST_F(UserTest, TestGetProviderData) { EXPECT_TRUE(provider.empty()); } -TEST_F(UserTest, TestUpdateEmail) { - const std::string config = - std::string( - "{" - " config:[" - " {fake:'FirebaseUser.updateEmail', futuregeneric:{ticker:1}}," - " {fake:'FIRUser.updateEmail:completion:', futuregeneric:" - "{ticker:1}},") + - SET_ACCOUNT_INFO_SUCCESSFUL_RESPONSE + - " ]" - "}"; - firebase::testing::cppsdk::ConfigSet(config.c_str()); - - EXPECT_NE("new@email.com", firebase_user_.email()); - Future result = firebase_user_.UpdateEmail("new@email.com"); - -// Fake Android & iOS implemented the delay. Desktop stub completed immediately. -#if defined(FIREBASE_ANDROID_FOR_DESKTOP) || FIREBASE_PLATFORM_IOS || \ - FIREBASE_PLATFORM_TVOS - EXPECT_EQ(firebase::kFutureStatusPending, result.status()); - EXPECT_NE("new@email.com", firebase_user_.email()); - firebase::testing::cppsdk::TickerElapse(); -#endif // defined(FIREBASE_ANDROID_FOR_DESKTOP) || FIREBASE_PLATFORM_IOS || - // FIREBASE_PLATFORM_TVOS - MaybeWaitForFuture(result); - EXPECT_EQ(firebase::kFutureStatusComplete, result.status()); - EXPECT_EQ(0, result.error()); - EXPECT_EQ("new@email.com", firebase_user_.email()); -} - TEST_F(UserTest, TestUpdatePassword) { const std::string config = std::string( diff --git a/release_build_files/readme.md b/release_build_files/readme.md index 0ecbafb0d9..34de676bcb 100644 --- a/release_build_files/readme.md +++ b/release_build_files/readme.md @@ -677,11 +677,7 @@ code. ## Release Notes ### Upcoming Release - Changes - - iOS: Added an option to explicitly specify your app's `AppDelegate` class - name via the `FirebaseAppDelegateClassName` key in `Info.plist`. This - provides a more direct way for Firebase to interact with your specified - AppDelegate. See "Platform Notes > iOS Method Swizzling > - Specifying Your AppDelegate Class Directly (iOS)" for details. + - Auth: Removed deprecated `User::UpdateEmail` method. ### 12.8.0 - Changes