Skip to content

Code sanitization #417

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

Merged
merged 2 commits into from
Mar 7, 2018
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
24 changes: 17 additions & 7 deletions FirebaseAuthUI/FUIAuth.m
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ - (void)signInWithProviderUI:(id<FUIAuthProvider>)providerUI
// Sign out first to make sure sign in starts with a clean state.
[providerUI signOut];
[providerUI signInWithDefaultValue:defaultValue
presentingViewController:presentingViewController
completion:^(FIRAuthCredential *_Nullable credential,
NSError *_Nullable error,
_Nullable FIRAuthResultCallback result) {
presentingViewController:presentingViewController
completion:^(FIRAuthCredential *_Nullable credential,
NSError *_Nullable error,
_Nullable FIRAuthResultCallback result) {
BOOL isAuthPickerShown =
[presentingViewController isKindOfClass:[FUIAuthPickerViewController class]];
if (error) {
Expand All @@ -177,12 +177,12 @@ - (void)signInWithProviderUI:(id<FUIAuthProvider>)providerUI
[self.auth signInAndRetrieveDataWithCredential:credential
completion:^(FIRAuthDataResult *_Nullable authResult,
NSError *_Nullable error) {
if (error && error.code == FIRAuthErrorCodeAccountExistsWithDifferentCredential) {
if (error.code == FIRAuthErrorCodeAccountExistsWithDifferentCredential) {
NSString *email = error.userInfo[kErrorUserInfoEmailKey];
[self handleAccountLinkingForEmail:email
newCredential:credential
presentingViewController:presentingViewController
singInResult:result];
signInResult:result];
return;
}

Expand All @@ -208,10 +208,20 @@ - (void)signInWithProviderUI:(id<FUIAuthProvider>)providerUI
}];
}

/** @fn handleAccountLinkingForEmail:newCredential:presentingViewController:signInResult
@brief Handles the account linking case after a user tries to sign-in which has a credential
with an email which is already used by a different account.
@param email The email address used by an existing account and and also the credential used in
the sign-in attempt.
@param newCredential The credential used in the lastest sign-in attempt.
@param presentingViewController The view controller used to present the UI.
@param signInResult block which takes the result of this method as a parameter; a nullable
AuthResult indicating success or a nullable Error indicating failure.
*/
- (void)handleAccountLinkingForEmail:(NSString *)email
newCredential:(FIRAuthCredential *)newCredential
presentingViewController:(UIViewController *)presentingViewController
singInResult:(_Nullable FIRAuthResultCallback) result {
signInResult:(_Nullable FIRAuthResultCallback)result {

[self.auth fetchProvidersForEmail:email
completion:^(NSArray<NSString *> *_Nullable providers,
Expand Down
2 changes: 1 addition & 1 deletion FirebaseAuthUI/FUIAuth_Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ NS_ASSUME_NONNULL_BEGIN
@see FUIAuthDelegate.authUI:didSignInWithAuthDataResult:error: for method callback.
@param providerUI The authentication provider used for signing in.
@param presentingViewController The view controller used to present the UI.
@param defaultValue The provider default initialization value (e g email or phone number)
@param defaultValue The provider default initialization value (e.g. email or phone number)
used for signing in.
*/
- (void)signInWithProviderUI:(id<FUIAuthProvider>)providerUI
Expand Down