Skip to content

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

Merged
merged 6 commits into from
Apr 15, 2025
Merged
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -612,41 +612,47 @@ static void handleAppleAuthResult(FLTFirebaseAuthPlugin *object, AuthPigeonFireb
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]);
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
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor

Choose a reason for hiding this comment

The 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);
}
}];
}
}

Expand Down
Loading