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

[Auth] Use 'password' for Email/Password provider ID #1201

Merged
merged 3 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion FirebaseAuthUI.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'FirebaseAuthUI'
s.version = '14.2.1'
s.version = '14.2.3'
s.summary = 'A prebuilt authentication UI flow for Firebase Auth.'
s.homepage = 'https://github.com/firebase/FirebaseUI-iOS'
s.license = { :type => 'Apache 2.0', :file => 'LICENSE' }
Expand Down
2 changes: 1 addition & 1 deletion FirebaseAuthUI/Sources/FUIAccountSettingsOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ - (void)showVerifyDialogWithMessage:(NSString *)message
alertMessage:message
alertCloseButton:FUILocalizedString(kStr_Cancel)
providerHandler:^(id<FIRUserInfo> provider) {
if (![provider.providerID isEqualToString:@"email"]) {
if (![provider.providerID isEqualToString:@"password"]) {
[self reauthenticateWithProvider:provider.providerID actionHandler:handler];
} else {
[self showVerifyPasswordViewWithMessage:message providerHandler:handler];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ - (void)showDeleteAccountDialog {
alertCloseButton:FUILocalizedString(kStr_Cancel)
providerHandler:^(id<FIRUserInfo> 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];
}];
Expand Down
10 changes: 5 additions & 5 deletions FirebaseAuthUI/Sources/FUIAccountSettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ - (FUIASAccountState)accountState {

for (id<FIRUserInfo> 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;
}
}
Expand Down Expand Up @@ -225,7 +225,7 @@ - (void)updateTableStateLinkedAccountWithoutEmail {
NSMutableArray *linkedAccounts =
[[NSMutableArray alloc] initWithCapacity:self.auth.currentUser.providerData.count];
for (id<FIRUserInfo> userInfo in self.auth.currentUser.providerData) {
if ([userInfo.providerID isEqualToString:@"email"]) {
if ([userInfo.providerID isEqualToString:@"password"]) {
continue;
}
FUIStaticContentTableViewCell *cell =
Expand Down Expand Up @@ -262,7 +262,7 @@ - (void)updateTableStateLinkedAccountWithEmail {
NSMutableArray *linkedAccounts =
[[NSMutableArray alloc] initWithCapacity:self.auth.currentUser.providerData.count];
for (id<FIRUserInfo> userInfo in self.auth.currentUser.providerData) {
if ([userInfo.providerID isEqualToString:@"email"]) {
if ([userInfo.providerID isEqualToString:@"password"]) {
continue;
}
FUIStaticContentTableViewCell *cell =
Expand Down Expand Up @@ -309,7 +309,7 @@ - (void)updateTableStateLinkedAccountWithEmailPassword {
NSMutableArray *linkedAccounts =
[[NSMutableArray alloc] initWithCapacity:self.auth.currentUser.providerData.count];
for (id<FIRUserInfo> userInfo in self.auth.currentUser.providerData) {
if ([userInfo.providerID isEqualToString:@"email"]) {
if ([userInfo.providerID isEqualToString:@"password"]) {
continue;
}
FUIStaticContentTableViewCell *cell =
Expand Down
2 changes: 1 addition & 1 deletion FirebaseAuthUI/Sources/FUIAuthBaseViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion FirebaseEmailAuthUI.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'FirebaseEmailAuthUI'
s.version = '14.2.0'
s.version = '14.2.3'
s.summary = 'An email authentication provider for FirebaseAuthUI.'
s.homepage = 'https://github.com/firebase/FirebaseUI-iOS'
s.license = { :type => 'Apache 2.0', :file => 'LICENSE' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)];
Expand Down
12 changes: 6 additions & 6 deletions FirebaseEmailAuthUI/Sources/FUIEmailAuth.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ + (NSBundle *)bundle {

- (instancetype)init {
return [self initAuthAuthUI:[FUIAuth defaultAuthUI]
signInMethod:@"email"
signInMethod:@"password"
forceSameDevice:NO
allowNewEmailAccounts:YES
requireDisplayName:YES
Expand Down Expand Up @@ -121,7 +121,7 @@ - (instancetype)initAuthAuthUI:(FUIAuth *)authUI
#pragma mark - FUIAuthProvider

- (nullable NSString *)providerID {
return @"email";
return @"password";
}

/** @fn accessToken:
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -856,7 +856,7 @@ - (nullable NSString *)authProviderFromProviders:(NSArray <NSString *> *) provid
NSSet *providerSet =
[NSSet setWithArray:@[ @"facebook.com",
@"google.com",
@"email" ]];
@"password" ]];
for (NSString *provider in providers) {
if ( [providerSet containsObject:provider]) {
return provider;
Expand Down
8 changes: 4 additions & 4 deletions FirebaseEmailAuthUI/Sources/FUIEmailEntryViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ - (void)next {
}

- (void)onNext:(NSString *)emailText {
FUIEmailAuth *emailAuth = [self.authUI providerWithID:@"email"];
FUIEmailAuth *emailAuth = [self.authUI providerWithID:@"password"];
id<FUIAuthDelegate> delegate = self.authUI.delegate;

if (![[self class] isValidEmail:emailText]) {
Expand All @@ -165,7 +165,7 @@ - (void)onNext:(NSString *)emailText {
}

id<FUIAuthProvider> 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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions UITests/FirebaseUISample/FUIViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ - (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];
} else if ([firstProviderID isEqualToString:FIRPhoneAuthProviderID]) {
FUIPhoneAuth *provider = _authProviders.firstObject;
[provider signInWithPresentingViewController:self phoneNumber:nil];
} else if ([firstProviderID isEqualToString:@
@"email"]) {
@"password"]) {
FUIEmailAuth *provider = _authProviders.firstObject;
[provider signInWithPresentingViewController:self email:nil];
}
Expand Down Expand Up @@ -439,7 +439,7 @@ - (void)prepareForAccountManagerWithoutPasswordWithLinkedAccountWithEmail {
- (id)createPasswordProvider {
id emailPasswordProviderMock = OCMProtocolMock(@protocol(FIRUserInfo));
OCMStub([emailPasswordProviderMock providerID]).andReturn(@
@"email");
@"password");
OCMStub([emailPasswordProviderMock email]).andReturn(@"[email protected]");
OCMStub([emailPasswordProviderMock displayName]).andReturn(@"password displayName");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -426,7 +426,7 @@ + (NSArray *)getListOfIDPs:(NSArray<NSIndexPath *> *)selectedRows
break;
case kIDPFacebook:
provider = useCustomScopes ? [[FUIFacebookAuth alloc] initWithAuthUI:[FUIAuth defaultAuthUI]
permissions:@[@"email",
permissions:@[@"password",
ncooke3 marked this conversation as resolved.
Show resolved Hide resolved
@"user_friends",
@"ads_read"]]
:[[FUIFacebookAuth alloc] initWithAuthUI:[FUIAuth defaultAuthUI]];
Expand Down