Skip to content

Commit

Permalink
More Firebase 11 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
paulb777 committed Jul 23, 2024
1 parent d599b6c commit 5f79644
Show file tree
Hide file tree
Showing 43 changed files with 127 additions and 115 deletions.
2 changes: 1 addition & 1 deletion FirebaseAnonymousAuthUI.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'FirebaseAnonymousAuthUI'
s.version = '14.1.0'
s.version = '14.2.0'
s.summary = 'Provides anonymous auth support 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 @@ -17,7 +17,7 @@
#import <OCMock/OCMock.h>
#import <XCTest/XCTest.h>

#import <FirebaseAuth/FirebaseAuth.h>
@import FirebaseAuth;
#import <FirebaseAuthUI/FirebaseAuthUI.h>

#import "FUIAnonymousAuth.h"
Expand Down
2 changes: 2 additions & 0 deletions FirebaseAnonymousAuthUI/Sources/FUIAnonymousAuth.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// limitations under the License.
//

@import FirebaseAuth;

#import <FirebaseAuthUI/FirebaseAuthUI.h>

#import "FirebaseAnonymousAuthUI/Sources/Public/FirebaseAnonymousAuthUI/FUIAnonymousAuth.h"
Expand Down
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.1.0'
s.version = '14.2.0'
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:FIREmailAuthProviderID]) {
if (![provider.providerID isEqualToString:@"email"]) {
[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 @@ -43,7 +43,8 @@ - (void)showDeleteAccountDialog {
alertMessage:FUILocalizedString(kStr_DeleteAccountBody)
alertCloseButton:FUILocalizedString(kStr_Cancel)
providerHandler:^(id<FIRUserInfo> provider) {
if (![provider.providerID isEqualToString:FIREmailAuthProviderID]) {
// TODO: Use public API after Firebase 11 minimum.
if (![provider.providerID isEqualToString:@"email"]) {
[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:FIREmailAuthProviderID]) {
![userInfo.providerID isEqualToString:@"email"]) {
hasEmailInLinkedProvider = YES;
}

if ([userInfo.providerID isEqualToString:FIREmailAuthProviderID]) {
if ([userInfo.providerID isEqualToString:@"email"]) {
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:FIREmailAuthProviderID]) {
if ([userInfo.providerID isEqualToString:@"email"]) {
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:FIREmailAuthProviderID]) {
if ([userInfo.providerID isEqualToString:@"email"]) {
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:FIREmailAuthProviderID]) {
if ([userInfo.providerID isEqualToString:@"email"]) {
continue;
}
FUIStaticContentTableViewCell *cell =
Expand Down
5 changes: 4 additions & 1 deletion FirebaseAuthUI/Sources/FUIAuth.m
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@ - (void)autoUpgradeAccountWithProviderUI:(id<FUIAuthProvider>)providerUI
if (error) {
// Check for "credential in use" conflict error and handle appropriately.
if (error.code == FIRAuthErrorCodeCredentialAlreadyInUse) {
FIRAuthCredential *newCredential = error.userInfo[FIRAuthErrorUserInfoUpdatedCredentialKey];
// TODO: When Firebase 11 is minimum update string to
// FIRAuthErrors.userInfoUpdatedCredentialKey
FIRAuthCredential *newCredential =
error.userInfo[@"FIRAuthErrorUserInfoUpdatedCredentialKey"];
NSDictionary *userInfo = @{ };
if (newCredential) {
userInfo = @{ FUIAuthCredentialKey : newCredential };
Expand Down
10 changes: 5 additions & 5 deletions FirebaseAuthUI/Sources/FUIAuthBaseViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#import "FirebaseAuthUI/Sources/Public/FirebaseAuthUI/FUIAuthBaseViewController_Internal.h"

#import <FirebaseAuth/FirebaseAuth.h>
@import FirebaseAuth;
#import <objc/runtime.h>

#import "FirebaseAuthUI/Sources/Public/FirebaseAuthUI/FUIAuthErrorUtils.h"
Expand Down Expand Up @@ -430,13 +430,13 @@ - (void)cancelAuthorization {
}

+ (NSString *)providerLocalizedName:(NSString *)providerId {
if ([providerId isEqualToString:FIREmailAuthProviderID]) {
if ([providerId isEqualToString:@"email"]) {
return FUILocalizedString(kStr_ProviderTitlePassword);
} else if ([providerId isEqualToString:FIRGoogleAuthProviderID]) {
} else if ([providerId isEqualToString:@"google.com"]) {
return FUILocalizedString(kStr_ProviderTitleGoogle);
} else if ([providerId isEqualToString:FIRFacebookAuthProviderID]) {
} else if ([providerId isEqualToString:@"facebook.com"]) {
return FUILocalizedString(kStr_ProviderTitleFacebook);
} else if ([providerId isEqualToString:FIRTwitterAuthProviderID]) {
} else if ([providerId isEqualToString:@"twitter.com"]) {
return FUILocalizedString(kStr_ProviderTitleTwitter);
}
return @"";
Expand Down
2 changes: 1 addition & 1 deletion FirebaseAuthUI/Sources/FUIAuthPickerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#import "FirebaseAuthUI/Sources/Public/FirebaseAuthUI/FUIAuthPickerViewController.h"

#import <AuthenticationServices/AuthenticationServices.h>
#import <FirebaseAuth/FirebaseAuth.h>
@import FirebaseAuth;

#import "FirebaseAuthUI/Sources/Public/FirebaseAuthUI/FUIAuthBaseViewController_Internal.h"
#import "FirebaseAuthUI/Sources/FUIAuthSignInButton.h"
Expand Down
2 changes: 1 addition & 1 deletion FirebaseAuthUI/Sources/FUIPrivacyAndTermsOfServiceView.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#import "FirebaseAuthUI/Sources/Public/FirebaseAuthUI/FUIPrivacyAndTermsOfServiceView.h"

#import <FirebaseAuth/FirebaseAuth.h>
@import FirebaseAuth;
#import "FirebaseAuthUI/Sources/Public/FirebaseAuthUI/FUIAuth.h"
#import "FirebaseAuthUI/Sources/Public/FirebaseAuthUI/FUIAuthStrings.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
//

#import <UIKit/UIKit.h>
#import <FirebaseAuth/FirebaseAuth.h>
@import FirebaseAuth;

@class FIRAuth;
@class FIRAuthCredential;
@class FIRUserInfo;

typedef void (^FIRAuthResultCallback)(FIRUser *_Nullable user, NSError *_Nullable error);

NS_ASSUME_NONNULL_BEGIN

/** @typedef FUIAuthProviderSignInCompletionBlock
Expand Down
2 changes: 1 addition & 1 deletion FirebaseDatabaseUI.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'FirebaseDatabaseUI'
s.version = '14.1.0'
s.version = '14.2.0'
s.summary = 'Prebuilt data sources and UI bindings for Firebase Database.'
s.homepage = 'https://github.com/firebase/FirebaseUI-iOS'
s.license = { :type => 'Apache 2.0', :file => 'LICENSE' }
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.1.0'
s.version = '14.2.0'
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 @@ -15,7 +15,7 @@
//

#import "FUIEmailAuth.h"
#import <FirebaseAuth/FirebaseAuth.h>
@import FirebaseAuth;
#import <FirebaseAuthUI/FUIAuthErrorUtils.h>
#import "FUIAuthUtils.h"
#import <FirebaseAuthUI/FUIAuth_Internal.h>
Expand Down
5 changes: 3 additions & 2 deletions FirebaseEmailAuthUI/Sources/FUIConfirmEmailViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#import "FirebaseEmailAuthUI/Sources/Public/FirebaseEmailAuthUI/FUIConfirmEmailViewController.h"

#import <FirebaseAuth/FirebaseAuth.h>
@import FirebaseAuth;

#import <FirebaseAuthUI/FirebaseAuthUI.h>

Expand Down Expand Up @@ -137,7 +137,8 @@ - (void)next {
}

- (void)onNext:(NSString *)emailText {
FUIEmailAuth *emailAuth = [self.authUI providerWithID:FIREmailAuthProviderID];
// TODO: After Firebase 11 minimum, change to EmailAuthProvider.id.
FUIEmailAuth *emailAuth = [self.authUI providerWithID:@"email"];

if (![[self class] isValidEmail:emailText]) {
[self showAlertWithMessage:FUILocalizedString(kStr_InvalidEmailError)];
Expand Down
36 changes: 18 additions & 18 deletions FirebaseEmailAuthUI/Sources/FUIEmailAuth.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@

#import "FirebaseEmailAuthUI/Sources/Public/FirebaseEmailAuthUI/FUIEmailAuth.h"

#import <FirebaseCore/FIRApp.h>
#import <FirebaseCore/FIROptions.h>
#import <FirebaseAuth/FirebaseAuth.h>
@import FirebaseCore;
@import FirebaseAuth;
#import <GoogleUtilities/GULUserDefaults.h>

#import <FirebaseAuthUI/FirebaseAuthUI.h>
Expand Down Expand Up @@ -78,7 +77,7 @@ + (NSBundle *)bundle {

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

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

/** @fn accessToken:
Expand Down Expand Up @@ -294,7 +293,7 @@ - (BOOL)handleOpenURL:(NSURL *)URL sourceApplication:(nullable NSString *)source
- (void)handleUnverifiedProviderLinking:(NSString *)providerID
email:(NSString *)email
error:(NSError **)error {
if ([providerID isEqualToString:FIRFacebookAuthProviderID]) {
if ([providerID isEqualToString:@"facebook.com"]) {
NSData *unverifiedProviderCredentialData = [GULUserDefaults.standardUserDefaults
objectForKey:kEmailLinkSignInLinkingCredentialKey];
FIRAuthCredential *unverifiedProviderCredential;
Expand Down Expand Up @@ -533,12 +532,12 @@ - (void)signInWithEmailHint:(NSString *)emailHint
NSString *existingFederatedProviderID = [self authProviderFromProviders:providers];
// Set of providers which can be auto-linked.
NSSet *supportedProviders =
[NSSet setWithObjects:FIRGoogleAuthProviderID,
FIRFacebookAuthProviderID,
FIREmailAuthProviderID,
[NSSet setWithObjects:@"google.com",
@"facebook.com",
@"email",
nil];
if ([supportedProviders containsObject:existingFederatedProviderID]) {
if ([existingFederatedProviderID isEqualToString:FIREmailAuthProviderID]) {
if ([existingFederatedProviderID isEqualToString:@"email"]) {

[FUIAuthBaseViewController showSignInAlertWithEmail:emailHint
providerShortName:@"Email/Password"
Expand Down Expand Up @@ -670,7 +669,7 @@ - (void)handleAccountLinkingForEmail:(NSString *)email
return;
}
NSString *bestProviderID = providers[0];
if ([bestProviderID isEqual:FIREmailAuthProviderID]) {
if ([bestProviderID isEqual:@"email"]) {
// Password verification.
UIViewController *passwordController;
if ([delegate respondsToSelector:
Expand All @@ -693,13 +692,14 @@ - (void)handleAccountLinkingForEmail:(NSString *)email
return;
}

if ([bestProviderID isEqual:FIREmailLinkAuthSignInMethod]) {
if ([bestProviderID isEqual:@"emailLink"]) {
NSString *providerName;
if ([newCredential.provider isEqualToString:FIRFacebookAuthProviderID]) {
if ([newCredential.provider isEqualToString:@"facebook.com"]) {
providerName = @"Facebook";
} else if ([newCredential.provider isEqualToString:FIRTwitterAuthProviderID]) {
} else if ([newCredential.provider isEqualToString:@"twitter.com"]) {
providerName = @"Twitter";
} else if ([newCredential.provider isEqualToString:FIRGitHubAuthProviderID]) {
} else if ([newCredential.provider isEqualToString:@"github.com"
@"twitter.com"]) {
providerName = @"Github";
}
NSString *message = [NSString stringWithFormat:
Expand Down Expand Up @@ -854,9 +854,9 @@ - (void)generateURLParametersAndLocalCache:(NSString *)email linkingProvider:(NS

- (nullable NSString *)authProviderFromProviders:(NSArray <NSString *> *) providers {
NSSet *providerSet =
[NSSet setWithArray:@[ FIRFacebookAuthProviderID,
FIRGoogleAuthProviderID,
FIREmailAuthProviderID ]];
[NSSet setWithArray:@[ @"facebook.com",
@"google.com",
@"email" ]];
for (NSString *provider in providers) {
if ( [providerSet containsObject:provider]) {
return provider;
Expand Down
14 changes: 8 additions & 6 deletions FirebaseEmailAuthUI/Sources/FUIEmailEntryViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#import "FirebaseEmailAuthUI/Sources/Public/FirebaseEmailAuthUI/FUIEmailEntryViewController.h"

#import <FirebaseAuth/FirebaseAuth.h>
@import FirebaseAuth;

#import <FirebaseAuthUI/FirebaseAuthUI.h>

Expand Down Expand Up @@ -138,7 +138,7 @@ - (void)next {
}

- (void)onNext:(NSString *)emailText {
FUIEmailAuth *emailAuth = [self.authUI providerWithID:FIREmailAuthProviderID];
FUIEmailAuth *emailAuth = [self.authUI providerWithID:@"email"];
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:FIREmailAuthProviderID]) {
if (provider && ![provider.providerID isEqualToString:@"email"]) {
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:FIREmailAuthProviderID]) {
} else if ([providers containsObject:@"email"]) {
UIViewController *controller;
if ([delegate respondsToSelector:@selector(passwordSignInViewControllerForAuthUI:email:)]) {
controller = [delegate passwordSignInViewControllerForAuthUI:self.authUI
Expand All @@ -186,7 +186,9 @@ - (void)onNext:(NSString *)emailText {
email:emailText];
}
[self pushViewController:controller];
} else if ([emailAuth.signInMethod isEqualToString:FIREmailLinkAuthSignInMethod]) {

// TODO: Use API to get string when Firebase 11 is the minimum.
} else if ([emailAuth.signInMethod isEqualToString:@"emailLink"]) {
[self sendSignInLinkToEmail:emailText];
} else {
if (providers.count) {
Expand Down Expand Up @@ -223,7 +225,7 @@ - (void)sendSignInLinkToEmail:(NSString*)email {
}

[self incrementActivity];
FUIEmailAuth *emailAuth = [self.authUI providerWithID:FIREmailAuthProviderID];
FUIEmailAuth *emailAuth = [self.authUI providerWithID:@"email"];
[emailAuth generateURLParametersAndLocalCache:email linkingProvider:nil];
[self.auth sendSignInLinkToEmail:email
actionCodeSettings:emailAuth.actionCodeSettings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

#import "FirebaseEmailAuthUI/Sources/Public/FirebaseEmailAuthUI/FUIPasswordRecoveryViewController.h"

#import <FirebaseAuth/FirebaseAuth.h>
@import FirebaseAuth;

#import <FirebaseAuthUI/FirebaseAuthUI.h>

#import "FirebaseEmailAuthUI/Sources/Public/FirebaseEmailAuthUI/FUIEmailAuth.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@

#import "FUIPasswordSignInViewController_Internal.h"

#import <FirebaseAuth/FirebaseAuth.h>
@import FirebaseAuth;
#import <FirebaseAuthUI/FirebaseAuthUI.h>

#import "FirebaseEmailAuthUI/Sources/Public/FirebaseEmailAuthUI/FUIEmailAuth.h"
#import "FirebaseEmailAuthUI/Sources/FUIEmailAuthStrings.h"
#import "FirebaseEmailAuthUI/Sources/Public/FirebaseEmailAuthUI/FUIPasswordRecoveryViewController.h"

typedef void (^FIRAuthDataResultCallback)(FIRAuthDataResult *_Nullable authResult,
NSError *_Nullable error);

/** @var kCellReuseIdentifier
@brief The reuse identifier for table view cell.
*/
Expand Down
Loading

0 comments on commit 5f79644

Please sign in to comment.