From 739da0b99c272b3b0aa249fffe2ab303093235b1 Mon Sep 17 00:00:00 2001 From: Nick Cooke Date: Thu, 15 Aug 2024 19:23:54 -0400 Subject: [PATCH] [Auth] Use 'password' for Email/Password provider ID --- FirebaseAuthUI/Sources/FUIAccountSettingsOperation.m | 2 +- .../FUIAccountSettingsOperationDeleteAccount.m | 2 +- .../Sources/FUIAccountSettingsViewController.m | 10 +++++----- FirebaseAuthUI/Sources/FUIAuthBaseViewController.m | 2 +- .../Sources/FUIConfirmEmailViewController.m | 2 +- FirebaseEmailAuthUI/Sources/FUIEmailAuth.m | 12 ++++++------ .../Sources/FUIEmailEntryViewController.m | 8 ++++---- UITests/FirebaseUISample/FUIViewController.m | 6 +++--- .../Samples/Auth/FUIAuthViewController.m | 4 ++-- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/FirebaseAuthUI/Sources/FUIAccountSettingsOperation.m b/FirebaseAuthUI/Sources/FUIAccountSettingsOperation.m index 0b6fb75962..c4dffd439b 100644 --- a/FirebaseAuthUI/Sources/FUIAccountSettingsOperation.m +++ b/FirebaseAuthUI/Sources/FUIAccountSettingsOperation.m @@ -230,7 +230,7 @@ - (void)showVerifyDialogWithMessage:(NSString *)message alertMessage:message alertCloseButton:FUILocalizedString(kStr_Cancel) providerHandler:^(id provider) { - if (![provider.providerID isEqualToString:@"email"]) { + if (![provider.providerID isEqualToString:@"password"]) { [self reauthenticateWithProvider:provider.providerID actionHandler:handler]; } else { [self showVerifyPasswordViewWithMessage:message providerHandler:handler]; diff --git a/FirebaseAuthUI/Sources/FUIAccountSettingsOperationDeleteAccount.m b/FirebaseAuthUI/Sources/FUIAccountSettingsOperationDeleteAccount.m index d2183696e2..65269bd1c5 100644 --- a/FirebaseAuthUI/Sources/FUIAccountSettingsOperationDeleteAccount.m +++ b/FirebaseAuthUI/Sources/FUIAccountSettingsOperationDeleteAccount.m @@ -44,7 +44,7 @@ - (void)showDeleteAccountDialog { alertCloseButton:FUILocalizedString(kStr_Cancel) providerHandler:^(id provider) { // TODO: Use public API after Firebase 11 minimum. - if (![provider.providerID isEqualToString:@"email"]) { + if (![provider.providerID isEqualToString:@"password"]) { [self reauthenticateWithProvider:provider.providerID actionHandler:^{ [self showDeleteAccountView]; }]; diff --git a/FirebaseAuthUI/Sources/FUIAccountSettingsViewController.m b/FirebaseAuthUI/Sources/FUIAccountSettingsViewController.m index 8700f592ad..059b026cee 100644 --- a/FirebaseAuthUI/Sources/FUIAccountSettingsViewController.m +++ b/FirebaseAuthUI/Sources/FUIAccountSettingsViewController.m @@ -79,11 +79,11 @@ - (FUIASAccountState)accountState { for (id userInfo in providers) { if (userInfo.email.length > 0 && - ![userInfo.providerID isEqualToString:@"email"]) { + ![userInfo.providerID isEqualToString:@"password"]) { hasEmailInLinkedProvider = YES; } - if ([userInfo.providerID isEqualToString:@"email"]) { + if ([userInfo.providerID isEqualToString:@"password"]) { hasPasswordProvider = YES; } } @@ -225,7 +225,7 @@ - (void)updateTableStateLinkedAccountWithoutEmail { NSMutableArray *linkedAccounts = [[NSMutableArray alloc] initWithCapacity:self.auth.currentUser.providerData.count]; for (id userInfo in self.auth.currentUser.providerData) { - if ([userInfo.providerID isEqualToString:@"email"]) { + if ([userInfo.providerID isEqualToString:@"password"]) { continue; } FUIStaticContentTableViewCell *cell = @@ -262,7 +262,7 @@ - (void)updateTableStateLinkedAccountWithEmail { NSMutableArray *linkedAccounts = [[NSMutableArray alloc] initWithCapacity:self.auth.currentUser.providerData.count]; for (id userInfo in self.auth.currentUser.providerData) { - if ([userInfo.providerID isEqualToString:@"email"]) { + if ([userInfo.providerID isEqualToString:@"password"]) { continue; } FUIStaticContentTableViewCell *cell = @@ -309,7 +309,7 @@ - (void)updateTableStateLinkedAccountWithEmailPassword { NSMutableArray *linkedAccounts = [[NSMutableArray alloc] initWithCapacity:self.auth.currentUser.providerData.count]; for (id userInfo in self.auth.currentUser.providerData) { - if ([userInfo.providerID isEqualToString:@"email"]) { + if ([userInfo.providerID isEqualToString:@"password"]) { continue; } FUIStaticContentTableViewCell *cell = diff --git a/FirebaseAuthUI/Sources/FUIAuthBaseViewController.m b/FirebaseAuthUI/Sources/FUIAuthBaseViewController.m index a5de7c73e3..d91ad5aa65 100644 --- a/FirebaseAuthUI/Sources/FUIAuthBaseViewController.m +++ b/FirebaseAuthUI/Sources/FUIAuthBaseViewController.m @@ -430,7 +430,7 @@ - (void)cancelAuthorization { } + (NSString *)providerLocalizedName:(NSString *)providerId { - if ([providerId isEqualToString:@"email"]) { + if ([providerId isEqualToString:@"password"]) { return FUILocalizedString(kStr_ProviderTitlePassword); } else if ([providerId isEqualToString:@"google.com"]) { return FUILocalizedString(kStr_ProviderTitleGoogle); diff --git a/FirebaseEmailAuthUI/Sources/FUIConfirmEmailViewController.m b/FirebaseEmailAuthUI/Sources/FUIConfirmEmailViewController.m index 8543db6269..90687777b5 100755 --- a/FirebaseEmailAuthUI/Sources/FUIConfirmEmailViewController.m +++ b/FirebaseEmailAuthUI/Sources/FUIConfirmEmailViewController.m @@ -138,7 +138,7 @@ - (void)next { - (void)onNext:(NSString *)emailText { // TODO: After Firebase 11 minimum, change to EmailAuthProvider.id. - FUIEmailAuth *emailAuth = [self.authUI providerWithID:@"email"]; + FUIEmailAuth *emailAuth = [self.authUI providerWithID:@"password"]; if (![[self class] isValidEmail:emailText]) { [self showAlertWithMessage:FUILocalizedString(kStr_InvalidEmailError)]; diff --git a/FirebaseEmailAuthUI/Sources/FUIEmailAuth.m b/FirebaseEmailAuthUI/Sources/FUIEmailAuth.m index 08efb77641..e20405a955 100644 --- a/FirebaseEmailAuthUI/Sources/FUIEmailAuth.m +++ b/FirebaseEmailAuthUI/Sources/FUIEmailAuth.m @@ -77,7 +77,7 @@ + (NSBundle *)bundle { - (instancetype)init { return [self initAuthAuthUI:[FUIAuth defaultAuthUI] - signInMethod:@"email" + signInMethod:@"password" forceSameDevice:NO allowNewEmailAccounts:YES requireDisplayName:YES @@ -121,7 +121,7 @@ - (instancetype)initAuthAuthUI:(FUIAuth *)authUI #pragma mark - FUIAuthProvider - (nullable NSString *)providerID { - return @"email"; + return @"password"; } /** @fn accessToken: @@ -534,10 +534,10 @@ - (void)signInWithEmailHint:(NSString *)emailHint NSSet *supportedProviders = [NSSet setWithObjects:@"google.com", @"facebook.com", - @"email", + @"password", nil]; if ([supportedProviders containsObject:existingFederatedProviderID]) { - if ([existingFederatedProviderID isEqualToString:@"email"]) { + if ([existingFederatedProviderID isEqualToString:@"password"]) { [FUIAuthBaseViewController showSignInAlertWithEmail:emailHint providerShortName:@"Email/Password" @@ -669,7 +669,7 @@ - (void)handleAccountLinkingForEmail:(NSString *)email return; } NSString *bestProviderID = providers[0]; - if ([bestProviderID isEqual:@"email"]) { + if ([bestProviderID isEqual:@"password"]) { // Password verification. UIViewController *passwordController; if ([delegate respondsToSelector: @@ -856,7 +856,7 @@ - (nullable NSString *)authProviderFromProviders:(NSArray *) provid NSSet *providerSet = [NSSet setWithArray:@[ @"facebook.com", @"google.com", - @"email" ]]; + @"password" ]]; for (NSString *provider in providers) { if ( [providerSet containsObject:provider]) { return provider; diff --git a/FirebaseEmailAuthUI/Sources/FUIEmailEntryViewController.m b/FirebaseEmailAuthUI/Sources/FUIEmailEntryViewController.m index d64e4da532..2cb16b3304 100755 --- a/FirebaseEmailAuthUI/Sources/FUIEmailEntryViewController.m +++ b/FirebaseEmailAuthUI/Sources/FUIEmailEntryViewController.m @@ -138,7 +138,7 @@ - (void)next { } - (void)onNext:(NSString *)emailText { - FUIEmailAuth *emailAuth = [self.authUI providerWithID:@"email"]; + FUIEmailAuth *emailAuth = [self.authUI providerWithID:@"password"]; id delegate = self.authUI.delegate; if (![[self class] isValidEmail:emailText]) { @@ -165,7 +165,7 @@ - (void)onNext:(NSString *)emailText { } id provider = [self bestProviderFromProviderIDs:providers]; - if (provider && ![provider.providerID isEqualToString:@"email"]) { + if (provider && ![provider.providerID isEqualToString:@"password"]) { NSString *email = emailText; [[self class] showSignInAlertWithEmail:email provider:provider @@ -176,7 +176,7 @@ - (void)onNext:(NSString *)emailText { cancelHandler:^{ [self.authUI signOutWithError:nil]; }]; - } else if ([providers containsObject:@"email"]) { + } else if ([providers containsObject:@"password"]) { UIViewController *controller; if ([delegate respondsToSelector:@selector(passwordSignInViewControllerForAuthUI:email:)]) { controller = [delegate passwordSignInViewControllerForAuthUI:self.authUI @@ -225,7 +225,7 @@ - (void)sendSignInLinkToEmail:(NSString*)email { } [self incrementActivity]; - FUIEmailAuth *emailAuth = [self.authUI providerWithID:@"email"]; + FUIEmailAuth *emailAuth = [self.authUI providerWithID:@"password"]; [emailAuth generateURLParametersAndLocalCache:email linkingProvider:nil]; [self.auth sendSignInLinkToEmail:email actionCodeSettings:emailAuth.actionCodeSettings diff --git a/UITests/FirebaseUISample/FUIViewController.m b/UITests/FirebaseUISample/FUIViewController.m index da7cd52bd4..58a7aea91a 100644 --- a/UITests/FirebaseUISample/FUIViewController.m +++ b/UITests/FirebaseUISample/FUIViewController.m @@ -85,7 +85,7 @@ - (IBAction)onAuthorization:(id)sender { BOOL shouldSkipPhoneAuthPicker = _authProviders.count == 1 && ([firstProviderID isEqualToString:FIRPhoneAuthProviderID] || [firstProviderID isEqualToString:@ -@"email"]); +@"password"]); if (!shouldSkipPhoneAuthPicker) { UIViewController *controller = [self.authUIMock authViewController]; [self presentViewController:controller animated:YES completion:nil]; @@ -93,7 +93,7 @@ - (IBAction)onAuthorization:(id)sender { FUIPhoneAuth *provider = _authProviders.firstObject; [provider signInWithPresentingViewController:self phoneNumber:nil]; } else if ([firstProviderID isEqualToString:@ -@"email"]) { +@"password"]) { FUIEmailAuth *provider = _authProviders.firstObject; [provider signInWithPresentingViewController:self email:nil]; } @@ -439,7 +439,7 @@ - (void)prepareForAccountManagerWithoutPasswordWithLinkedAccountWithEmail { - (id)createPasswordProvider { id emailPasswordProviderMock = OCMProtocolMock(@protocol(FIRUserInfo)); OCMStub([emailPasswordProviderMock providerID]).andReturn(@ -@"email"); +@"password"); OCMStub([emailPasswordProviderMock email]).andReturn(@"password@email.com"); OCMStub([emailPasswordProviderMock displayName]).andReturn(@"password displayName"); diff --git a/samples/objc/FirebaseUI-demo-objc/Samples/Auth/FUIAuthViewController.m b/samples/objc/FirebaseUI-demo-objc/Samples/Auth/FUIAuthViewController.m index 74d19cd47d..4635a0cc7c 100644 --- a/samples/objc/FirebaseUI-demo-objc/Samples/Auth/FUIAuthViewController.m +++ b/samples/objc/FirebaseUI-demo-objc/Samples/Auth/FUIAuthViewController.m @@ -263,7 +263,7 @@ - (IBAction)onAuthorization:(id)sender { NSString *providerID = self.authUI.providers.firstObject.providerID; BOOL isPhoneAuth = [providerID isEqualToString:FIRPhoneAuthProviderID]; BOOL isEmailAuth = [providerID isEqualToString:@ -@"email"]; +@"password"]; BOOL shouldSkipAuthPicker = self.authUI.providers.count == 1 && (isPhoneAuth || isEmailAuth); if (shouldSkipAuthPicker) { if (isPhoneAuth) { @@ -426,7 +426,7 @@ + (NSArray *)getListOfIDPs:(NSArray *)selectedRows break; case kIDPFacebook: provider = useCustomScopes ? [[FUIFacebookAuth alloc] initWithAuthUI:[FUIAuth defaultAuthUI] - permissions:@[@"email", + permissions:@[@"password", @"user_friends", @"ads_read"]] :[[FUIFacebookAuth alloc] initWithAuthUI:[FUIAuth defaultAuthUI]];