Skip to content

Commit 6631da6

Browse files
authored
feat(auth): improve error message when user cancels a sign in with a provider (#10060)
* feat(auth): improve error message when user cancels a sign in with a provider * feat: formatting
1 parent 8aa6c7c commit 6631da6

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

packages/firebase_auth/firebase_auth/ios/Classes/FLTFirebaseAuthPlugin.m

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,33 @@ - (void)authorizationController:(ASAuthorizationController *)controller
622622
- (void)authorizationController:(ASAuthorizationController *)controller
623623
didCompleteWithError:(NSError *)error API_AVAILABLE(macos(10.15), ios(13.0)) {
624624
NSLog(@"Sign in with Apple errored: %@", error);
625-
self.appleResult.error(nil, nil, nil, error);
625+
switch (error.code) {
626+
case ASAuthorizationErrorCanceled:
627+
self.appleResult.error(@"canceled", @"The user canceled the authorization attempt.", nil,
628+
error);
629+
break;
630+
631+
case ASAuthorizationErrorInvalidResponse:
632+
self.appleResult.error(@"invalid-response",
633+
@"The authorization request received an invalid response.", nil,
634+
error);
635+
break;
636+
637+
case ASAuthorizationErrorNotHandled:
638+
self.appleResult.error(@"not-handled", @"The authorization request wasn’t handled.", nil,
639+
error);
640+
break;
641+
642+
case ASAuthorizationErrorFailed:
643+
self.appleResult.error(@"failed", @"The authorization attempt failed.", nil, error);
644+
break;
645+
646+
case ASAuthorizationErrorUnknown:
647+
default:
648+
self.appleResult.error(nil, nil, nil, error);
649+
break;
650+
}
651+
self.appleResult = nil;
626652
}
627653

628654
- (void)signInWithProvider:(id)arguments

0 commit comments

Comments
 (0)