@@ -52,31 +52,37 @@ firebaseui.auth.widget.handler.handleCallback =
5252 firebaseui . auth . widget . handler . handleCallbackResult_ ( app , component ,
5353 result ) ;
5454 } , function ( error ) {
55+ // Normalize the error.
56+ const normalizedError =
57+ firebaseui . auth . widget . handler . common . normalizeError ( error ) ;
5558 // A previous redirect operation was triggered and some error occurred.
5659 // Test for need confirmation error and handle appropriately.
5760 // For all other errors, display info bar and show sign in screen.
58- if ( error &&
61+ if ( normalizedError &&
5962 // Single out need confirmation error as email-already-in-use and
6063 // credential-already-in-use will also return email and credential
6164 // and need to be handled differently.
62- ( error [ 'code' ] == 'auth/account-exists-with-different-credential' ||
63- error [ 'code' ] == 'auth/email-already-in-use' ) &&
64- error [ 'email' ] &&
65- error [ 'credential' ] ) {
65+ ( normalizedError [ 'code' ] ==
66+ 'auth/account-exists-with-different-credential' ||
67+ normalizedError [ 'code' ] == 'auth/email-already-in-use' ) &&
68+ normalizedError [ 'email' ] &&
69+ normalizedError [ 'credential' ] ) {
6670 // Save pending email credential.
6771 firebaseui . auth . storage . setPendingEmailCredential (
6872 new firebaseui . auth . PendingEmailCredential (
69- error [ 'email' ] , error [ 'credential' ] ) ,
73+ normalizedError [ 'email' ] , normalizedError [ 'credential' ] ) ,
7074 app . getAppId ( ) ) ;
7175 firebaseui . auth . widget . handler . handleCallbackLinking_ (
72- app , component , error [ 'email' ] ) ;
73- } else if ( error && error [ 'code' ] == 'auth/user-cancelled' ) {
76+ app , component , normalizedError [ 'email' ] ) ;
77+ } else if ( normalizedError &&
78+ normalizedError [ 'code' ] == 'auth/user-cancelled' ) {
7479 // Should go back to the previous linking screen. A pending email
7580 // should be present, otherwise there's an error.
76- var pendingCredential =
81+ const pendingCredential =
7782 firebaseui . auth . storage . getPendingEmailCredential ( app . getAppId ( ) ) ;
78- var message =
79- firebaseui . auth . widget . handler . common . getErrorMessage ( error ) ;
83+ const message =
84+ firebaseui . auth . widget . handler . common . getErrorMessage (
85+ normalizedError ) ;
8086 // If there is a credential too, then the previous screen was federated
8187 // linking so we process the error as a linking flow.
8288 if ( pendingCredential && pendingCredential . getCredential ( ) ) {
@@ -92,14 +98,17 @@ firebaseui.auth.widget.handler.handleCallback =
9298 } else {
9399 // Go to the sign-in page with info bar error.
94100 firebaseui . auth . widget . handler . handleCallbackFailure_ (
95- app , component , /** @type {!Error } */ ( error ) ) ;
101+ app , component , /** @type {!Error } */ ( normalizedError ) ) ;
96102 }
97- } else if ( error && error [ 'code' ] == 'auth/credential-already-in-use' ) {
103+ } else if ( normalizedError &&
104+ normalizedError [ 'code' ] == 'auth/credential-already-in-use' ) {
98105 // Do nothing and keep callback UI while onUpgradeError catches and
99106 // handles this error.
100- } else if ( error &&
101- error [ 'code' ] == 'auth/operation-not-supported-in-this-environment' &&
102- firebaseui . auth . widget . handler . common . isPasswordProviderOnly ( app ) ) {
107+ } else if ( normalizedError &&
108+ normalizedError [ 'code' ] ==
109+ 'auth/operation-not-supported-in-this-environment' &&
110+ firebaseui . auth . widget . handler . common . isPasswordProviderOnly (
111+ app ) ) {
103112 // Operation is not supported in this environment but only password
104113 // provider is enabled. So allow this to proceed as a no redirect result.
105114 // This will allow developers using password sign-in in Cordova to use
@@ -114,7 +123,7 @@ firebaseui.auth.widget.handler.handleCallback =
114123 } else {
115124 // Go to the sign-in page with info bar error.
116125 firebaseui . auth . widget . handler . handleCallbackFailure_ (
117- app , component , /** @type {!Error } */ ( error ) ) ;
126+ app , component , /** @type {!Error } */ ( normalizedError ) ) ;
118127 }
119128 } ) ) ;
120129} ;
0 commit comments