Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions FirebaseAuthUI/FUIAuth.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ __attribute__((deprecated("Instead use authUI:didSignInWithAuthDataResult:error:
*/
@property(nonatomic, assign, getter=isSignInWithEmailHidden) BOOL signInWithEmailHidden;

/** @property allowNewEmailAccounts
@brief Whether to allow new user sign, defaults to YES.
*/
@property(nonatomic, assign) BOOL allowNewEmailAccounts;

/** @property customStringsBundle
@brief Custom strings bundle supplied by the developer. Nil when there is no custom strings
bundle set. In which case the default bundle will be used.
Expand Down
21 changes: 16 additions & 5 deletions FirebaseAuthUI/FUIAuth.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#import "FUIAuthStrings.h"
#import "FUIEmailEntryViewController.h"
#import "FUIPasswordVerificationViewController.h"
#import "FUIPasswordSignInViewController.h"

/** @var kAppNameCodingKey
@brief The key used to encode the app Name for NSCoding.
Expand Down Expand Up @@ -104,6 +105,7 @@ + (nullable FUIAuth *)authUIWithAuth:(FIRAuth *)auth {
- (instancetype)initWithAuth:(FIRAuth *)auth {
self = [super init];
if (self) {
_allowNewEmailAccounts = YES;
_auth = auth;
}
return self;
Expand All @@ -125,11 +127,20 @@ - (UINavigationController *)authViewController {
UIViewController *controller;

if (self.providers.count == 0 && !self.isSignInWithEmailHidden) {
if ([self.delegate respondsToSelector:@selector(emailEntryViewControllerForAuthUI:)]) {
controller = [self.delegate emailEntryViewControllerForAuthUI:self];
} else {
controller = [[FUIEmailEntryViewController alloc] initWithAuthUI:self];
}
if (self.allowNewEmailAccounts) {
if ([self.delegate respondsToSelector:@selector(emailEntryViewControllerForAuthUI:)]) {
controller = [self.delegate emailEntryViewControllerForAuthUI:self];
} else {
controller = [[FUIEmailEntryViewController alloc] initWithAuthUI:self];
}
}
else {
if ([self.delegate respondsToSelector:@selector(emailEntryViewControllerForAuthUI:)]) {
controller = [self.delegate passwordSignInViewControllerForAuthUI:self email:@""];
} else {
controller = [[FUIPasswordSignInViewController alloc] initWithAuthUI:self email:nil];
}
}
} else if ([self.delegate respondsToSelector:@selector(authPickerViewControllerForAuthUI:)]) {
controller = [self.delegate authPickerViewControllerForAuthUI:self];
} else {
Expand Down
12 changes: 8 additions & 4 deletions FirebaseAuthUI/FUIEmailEntryViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,16 @@ - (void)onNext:(NSString *)emailText {
} else {
// New user.
UIViewController *controller;
if ([self.authUI.delegate respondsToSelector:@selector(passwordSignUpViewControllerForAuthUI:email:)]) {
controller = [self.authUI.delegate passwordSignUpViewControllerForAuthUI:self.authUI
if (self.authUI.allowNewEmailAccounts) {
if ([self.authUI.delegate respondsToSelector:@selector(passwordSignUpViewControllerForAuthUI:email:)]) {
controller = [self.authUI.delegate passwordSignUpViewControllerForAuthUI:self.authUI
email:emailText];
} else {
controller = [[FUIPasswordSignUpViewController alloc] initWithAuthUI:self.authUI
} else {
controller = [[FUIPasswordSignUpViewController alloc] initWithAuthUI:self.authUI
email:emailText];
}
} else {
[self showAlertWithMessage:FUILocalizedString(kStr_UserNotFoundError)];
}
[self pushViewController:controller];
}
Expand Down
17 changes: 17 additions & 0 deletions FirebaseAuthUI/FUIPasswordSignInViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,23 @@ - (void)viewDidLoad {
[self enableDynamicCellHeightForTableView:_tableView];
}

- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];

if (self.navigationController.viewControllers.firstObject == self) {
UIBarButtonItem *cancelBarButton =
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self
action:@selector(cancelAuthorization)];
self.navigationItem.leftBarButtonItem = cancelBarButton;
self.navigationItem.backBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:FUILocalizedString(kStr_Back)
style:UIBarButtonItemStylePlain
target:nil
action:nil];
}
}

#pragma mark - Actions

- (void)signInWithDefaultValue:(NSString *)email andPassword:(NSString *)password {
Expand Down