Skip to content

Conversation

@protocol86
Copy link
Contributor

Adds flow to sign into an existing email/password user (on a separate auth instance) before linking this user to the federated auth credential during a merge conflict while upgrading anonymous user.

[self.navigationController dismissViewControllerAnimated:YES completion:^{
[self.authUI invokeResultCallbackWithAuthDataResult:authResult error:error];
if (self->_onDismissCallback) {
self->_onDismissCallback(authResult, error);
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

in this block if necessary.
@param callback The custom callback to execute during dismissal of the view controller.
*/
- (void)setOnDismissCallback:(FIRAuthDataResultCallback)callback;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just make it a property called completion, with initial value being the what we're doing by default. If you do that, make sure you only capture weak self in the block.

Alternatively you can use the delegate pattern but that might be too heavy-handed if you don't expect more methods in the delegate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks!

Copy link
Contributor

@morganchen12 morganchen12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor notes, otherwise looks good.


- (void)signInWithEmailHint:(NSString *)emailHint
presentingViewController:(UIViewController *)presentingViewController
presentingViewController:(FUIAuthBaseViewController *)presentingViewController
Copy link
Contributor

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 case UIViewController should be ok. If this is public API, we want to provide the highest-level types possible.

Copy link
Contributor Author

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. The pushViewController: method being used here is a custom method which modifies the way the navigation bar is presented when the view controller is pushed.

NSError *_Nullable error,
FIRAuthResultCallback _Nullable result) {
if (error) {
completion(nil, error);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

completion may be nil.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

/** @var _onDismissCallback
@brief The callback to be executed during view controller dismissal.
*/
FIRAuthDataResultCallback _onDismissCallback;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better name might be onSuccessfulLoginCallback, since this block will not be called if the controller is dismissed by exiting the login flow.

@protocol86 protocol86 merged commit a73dbf7 into anonymous_updgrade_master Feb 23, 2018
protocol86 added a commit that referenced this pull request Jul 17, 2018
…ederated credential (#410)

* Adds email/password “email-already-in-use” flow

* addresses commnets

* Addresses comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants