Skip to content

Commit

Permalink
Code sanitization (#417)
Browse files Browse the repository at this point in the history
* Code sanitization

- Aligns colons
- Removes uncessary nil check
- documents internal method
- Fixes minor typos

* Addresses comments
  • Loading branch information
protocol86 authored Mar 7, 2018
1 parent b1e7ea3 commit d614ad4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
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

0 comments on commit d614ad4

Please sign in to comment.