-
Notifications
You must be signed in to change notification settings - Fork 488
Adds email/password “email-already-in-use” flow when upgrading to a federated credential #410
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |
| // limitations under the License. | ||
| // | ||
|
|
||
| #import "FUIPasswordSignInViewController.h" | ||
| #import "FUIPasswordSignInViewController_Internal.h" | ||
|
|
||
| #import <FirebaseAuth/FirebaseAuth.h> | ||
| #import "FUIAuthBaseViewController_Internal.h" | ||
|
|
@@ -80,6 +80,10 @@ - (instancetype)initWithNibName:(nullable NSString *)nibNameOrNil | |
| _email = [email copy]; | ||
|
|
||
| self.title = FUILocalizedString(kStr_SignInTitle); | ||
| __weak FUIPasswordSignInViewController *weakself = self; | ||
| _onDismissCallback = ^(FIRAuthDataResult *authResult, NSError *error){ | ||
| [weakself.authUI invokeResultCallbackWithAuthDataResult:authResult error:error]; | ||
| }; | ||
| } | ||
| return self; | ||
| } | ||
|
|
@@ -134,7 +138,9 @@ - (void)signInWithDefaultValue:(NSString *)email andPassword:(NSString *)passwor | |
| } | ||
| } | ||
| [self.navigationController dismissViewControllerAnimated:YES completion:^{ | ||
| [self.authUI invokeResultCallbackWithAuthDataResult:authResult error:error]; | ||
| if (self->_onDismissCallback) { | ||
| self->_onDismissCallback(authResult, error); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is usually a good idea to nil-out callback blocks after use to avoid circular references.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I went with the property approach outlined in you other comment. Since the block will be reused I leave it up to the developer using a custom block to decide whether or not it should be set to nil. |
||
| } | ||
| }]; | ||
| }; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // | ||
| // Copyright (c) 2018 Google Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // | ||
|
|
||
| #import "FUIPasswordSignInViewController.h" | ||
| #import <FirebaseAuth/FirebaseAuth.h> | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| @interface FUIPasswordSignInViewController () | ||
|
|
||
| /** @property onDismissCallback: | ||
| @brief Sets an optional custom callback for FUIPasswordSigInViewController during dismissal. If | ||
| this property is set the default dismissal routine is not triggered and should be included | ||
| in this block if necessary. This block is NOT set to nil after use, set to nil after using | ||
| if you wish to avoid circular references. | ||
| */ | ||
| @property(nonatomic, strong, nullable) FIRAuthDataResultCallback onDismissCallback; | ||
|
|
||
| NS_ASSUME_NONNULL_END | ||
|
|
||
|
|
||
| @end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like the only method being used on these controllers is
pushViewController:, in which caseUIViewControllershould be ok. If this is public API, we want to provide the highest-level types possible.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
signInWithEmailHint:presentingViewController:completion:isn't a public API, it's only used for a special case of automatic upgrade behind the scenes. ThepushViewController:method being used here is a custom method which modifies the way the navigation bar is presented when the view controller is pushed.