-
Notifications
You must be signed in to change notification settings - Fork 4k
fix(auth, iOS): include missing email and credential in account-exists-with-different-credential error #17180
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
Changes from all commits
28f8df8
d596aa1
54d6b21
00a04f8
2bf5fe9
cc5133c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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"]) { | ||
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. Can we compare |
||
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); | ||
} | ||
}]; | ||
} | ||
} | ||
|
||
|
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?