Skip to content

Conversation

@protocol86
Copy link
Contributor

Adds logic to link a federated account with an existing google account if they share the same email during anonynous user upgrade.

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.

Had some comments on callback handling, otherwise LGTM.

code:FUIAuthErrorCodeMergeConflict
userInfo:userInfo];
result(nil, mergeError);
completeSignInBlock(authResult, mergeError);
Copy link
Contributor

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.

  1. result is called on line 216. mergeError is nonnull.
  2. completeSignInBlock() is called with nonnull result.
    • result is called again on line 182 with nil, nil as its arguments.

Also, this is an unguarded call to result, which 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.

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);
Copy link
Contributor

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.

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

NSError *_Nullable error) {
if (error) {
result(nil, error);
completeSignInBlock(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.

See above comment

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

code:FUIAuthErrorCodeMergeConflict
userInfo:userInfo];
result(nil, mergeError);
completeSignInBlock(authResult, mergeError);
Copy link
Contributor

Choose a reason for hiding this comment

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

See above comment

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

return;
}

[auth signInAndRetrieveDataWithCredential:credential completion:completion];
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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 :)

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.


- (nullable NSString *)federatedAuthProviderFromProviders:(NSArray <NSString *> *) providers {
NSSet *providerSet =
[[NSSet alloc] initWithArray:@[ FIRFacebookAuthProviderID, FIRGoogleAuthProviderID ]];
Copy link
Contributor

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.

Copy link
Contributor Author

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 :).

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.

LGTM, thanks!

@protocol86 protocol86 merged commit b9cc5df into anonymous_updgrade_master Feb 15, 2018
protocol86 added a commit that referenced this pull request Jul 17, 2018
* Adds anonymous upgrade for Google email conflict

* Addresses comments

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

2 participants