-
Notifications
You must be signed in to change notification settings - Fork 488
Adds anonymous upgrade for google account email conflict #407
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
Adds anonymous upgrade for google account email conflict #407
Conversation
morganchen12
left a comment
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.
Had some comments on callback handling, otherwise LGTM.
| code:FUIAuthErrorCodeMergeConflict | ||
| userInfo:userInfo]; | ||
| result(nil, mergeError); | ||
| completeSignInBlock(authResult, mergeError); |
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.
I know this isn't part of the change, but can this cause result to be called twice? Say result is nonnull.
resultis called on line 216.mergeErroris nonnull.completeSignInBlock()is called with nonnullresult.resultis called again on line 182 withnil, nilas its arguments.
Also, this is an unguarded call to result, which may be nil.
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.
that's a good catch, we seemed to have forgotten to remove this call after adding the completeSignInBlock.
| NSError *_Nullable error) { | ||
| if (error) { | ||
| result(nil, error); | ||
| completeSignInBlock(nil, error); |
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.
The comment above also applies here.
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.
done
| NSError *_Nullable error) { | ||
| if (error) { | ||
| result(nil, error); | ||
| completeSignInBlock(nil, error); |
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.
See above comment
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.
done
| code:FUIAuthErrorCodeMergeConflict | ||
| userInfo:userInfo]; | ||
| result(nil, mergeError); | ||
| completeSignInBlock(authResult, mergeError); |
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.
See above comment
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.
done
| return; | ||
| } | ||
|
|
||
| [auth signInAndRetrieveDataWithCredential:credential completion:completion]; |
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.
Why does this use a different auth instance?
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.
Because we need to complete a sign-in of the existing credential before linking; however we do not want to lose the currently signed in user. A sign-in operation usually replaces the currently signed-in user if successful.
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.
Maybe add a comment describing that :)
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.
Done.
FirebaseAuthUI/FUIAuth.m
Outdated
|
|
||
| - (nullable NSString *)federatedAuthProviderFromProviders:(NSArray <NSString *> *) providers { | ||
| NSSet *providerSet = | ||
| [[NSSet alloc] initWithArray:@[ FIRFacebookAuthProviderID, FIRGoogleAuthProviderID ]]; |
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.
nit: use +[NSSet setWithArray:]
Also, using NSSet for a faster contains when searching an array is not necessarily faster than using containsObject: on the array directly, since some cost is incurred when creating the set.
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.
Agreed, using the class method but leaving the set, just don't like the idea of creating an array for the sole purpose of look up :).
morganchen12
left a comment
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.
LGTM, thanks!
* Adds anonymous upgrade for Google email conflict * Addresses comments * Addresses comments.
Adds logic to link a federated account with an existing google account if they share the same email during anonynous user upgrade.