-
Notifications
You must be signed in to change notification settings - Fork 4k
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
fix(auth, iOS): include missing email and credential in account-exists-with-different-credential error #17180
Open
SelaseKay
wants to merge
5
commits into
main
Choose a base branch
from
auth_17160
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
28f8df8
fix(auth, iOS): include missing email and credential in account-exist…
SelaseKay d596aa1
chore: use `convertToFlutterError` function
SelaseKay 54d6b21
chore: revert indentation
SelaseKay 00a04f8
chore: revert indentation
SelaseKay 2bf5fe9
chore: fix formatting issues
SelaseKay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -602,51 +602,58 @@ static void handleAppleAuthResult(FLTFirebaseAuthPlugin *object, AuthPigeonFireb | |
return; | ||
} | ||
if (credentials) { | ||
[auth signInWithCredential:credentials | ||
completion:^(FIRAuthDataResult *authResult, NSError *error) { | ||
if (error != nil) { | ||
NSDictionary *userInfo = [error userInfo]; | ||
NSError *underlyingError = [userInfo objectForKey:NSUnderlyingErrorKey]; | ||
|
||
NSDictionary *firebaseDictionary = | ||
underlyingError.userInfo[@"FIRAuthErrorUserInfoDes" | ||
@"erializedResponseKey"]; | ||
|
||
if (firebaseDictionary == nil && | ||
userInfo[@"FIRAuthErrorUserInfoNameKey"] != nil) { | ||
// Removing since it's not parsed and causing issue when sending back the | ||
// object to Flutter | ||
NSMutableDictionary *mutableUserInfo = [userInfo mutableCopy]; | ||
[mutableUserInfo | ||
removeObjectForKey:@"FIRAuthErrorUserInfoUpdatedCredentialKey"]; | ||
NSError *modifiedError = [NSError errorWithDomain:error.domain | ||
code:error.code | ||
userInfo:mutableUserInfo]; | ||
|
||
completion(nil, | ||
[FlutterError errorWithCode:@"sign-in-failed" | ||
message:userInfo[@"NSLocalizedDescription"] | ||
details:modifiedError.userInfo]); | ||
|
||
} else if (firebaseDictionary != nil && | ||
firebaseDictionary[@"message"] != nil) { | ||
// error from firebase-ios-sdk is | ||
// buried in underlying error. | ||
completion(nil, | ||
[FlutterError errorWithCode:@"sign-in-failed" | ||
message:error.localizedDescription | ||
details:firebaseDictionary[@"message"]]); | ||
} else { | ||
completion(nil, [FlutterError errorWithCode:@"sign-in-failed" | ||
message:error.localizedDescription | ||
details:error.userInfo]); | ||
[auth | ||
signInWithCredential:credentials | ||
completion:^(FIRAuthDataResult *authResult, NSError *error) { | ||
if (error != nil) { | ||
NSDictionary *userInfo = [error userInfo]; | ||
NSError *underlyingError = [userInfo objectForKey:NSUnderlyingErrorKey]; | ||
|
||
NSDictionary *firebaseDictionary = | ||
underlyingError.userInfo[@"FIRAuthErrorUserInfoDes" | ||
@"erializedResponseKey"]; | ||
|
||
NSString *errorCode = userInfo[@"FIRAuthErrorUserInfoNameKey"]; | ||
|
||
if (firebaseDictionary == nil && errorCode != nil) { | ||
if ([errorCode isEqual:@"ERROR_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL"]) { | ||
completion(nil, [FLTFirebaseAuthPlugin convertToFlutterError:error]); | ||
return; | ||
} | ||
|
||
// Removing since it's not parsed and causing issue when sending back the | ||
// object to Flutter | ||
NSMutableDictionary *mutableUserInfo = [userInfo mutableCopy]; | ||
[mutableUserInfo | ||
removeObjectForKey:@"FIRAuthErrorUserInfoUpdatedCredentialKey"]; | ||
NSError *modifiedError = [NSError errorWithDomain:error.domain | ||
code:error.code | ||
userInfo:mutableUserInfo]; | ||
|
||
completion(nil, | ||
[FlutterError errorWithCode:@"sign-in-failed" | ||
message:userInfo[@"NSLocalizedDescription"] | ||
details:modifiedError.userInfo]); | ||
|
||
} else if (firebaseDictionary != nil && | ||
firebaseDictionary[@"message"] != nil) { | ||
// error from firebase-ios-sdk is | ||
// buried in underlying error. | ||
completion(nil, | ||
[FlutterError errorWithCode:@"sign-in-failed" | ||
message:error.localizedDescription | ||
details:firebaseDictionary[@"message"]]); | ||
} else { | ||
completion([PigeonParser getPigeonUserCredentialFromAuthResult:authResult | ||
authorizationCode:nil], | ||
nil); | ||
Comment on lines
-645
to
-647
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see here that you have changed the order in completion, is this intentional? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My mistake it's because the whole indentation changed 😓 |
||
completion(nil, [FlutterError errorWithCode:@"sign-in-failed" | ||
message:error.localizedDescription | ||
details:error.userInfo]); | ||
} | ||
}]; | ||
} else { | ||
completion([PigeonParser getPigeonUserCredentialFromAuthResult:authResult | ||
authorizationCode:nil], | ||
nil); | ||
} | ||
}]; | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 whole indentation changed because of this which makes reviewing harder, why formatting changed?