@@ -52,31 +52,37 @@ firebaseui.auth.widget.handler.handleCallback =
52
52
firebaseui . auth . widget . handler . handleCallbackResult_ ( app , component ,
53
53
result ) ;
54
54
} , function ( error ) {
55
+ // Normalize the error.
56
+ const normalizedError =
57
+ firebaseui . auth . widget . handler . common . normalizeError ( error ) ;
55
58
// A previous redirect operation was triggered and some error occurred.
56
59
// Test for need confirmation error and handle appropriately.
57
60
// For all other errors, display info bar and show sign in screen.
58
- if ( error &&
61
+ if ( normalizedError &&
59
62
// Single out need confirmation error as email-already-in-use and
60
63
// credential-already-in-use will also return email and credential
61
64
// 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' ] ) {
66
70
// Save pending email credential.
67
71
firebaseui . auth . storage . setPendingEmailCredential (
68
72
new firebaseui . auth . PendingEmailCredential (
69
- error [ 'email' ] , error [ 'credential' ] ) ,
73
+ normalizedError [ 'email' ] , normalizedError [ 'credential' ] ) ,
70
74
app . getAppId ( ) ) ;
71
75
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' ) {
74
79
// Should go back to the previous linking screen. A pending email
75
80
// should be present, otherwise there's an error.
76
- var pendingCredential =
81
+ const pendingCredential =
77
82
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 ) ;
80
86
// If there is a credential too, then the previous screen was federated
81
87
// linking so we process the error as a linking flow.
82
88
if ( pendingCredential && pendingCredential . getCredential ( ) ) {
@@ -92,14 +98,17 @@ firebaseui.auth.widget.handler.handleCallback =
92
98
} else {
93
99
// Go to the sign-in page with info bar error.
94
100
firebaseui . auth . widget . handler . handleCallbackFailure_ (
95
- app , component , /** @type {!Error } */ ( error ) ) ;
101
+ app , component , /** @type {!Error } */ ( normalizedError ) ) ;
96
102
}
97
- } else if ( error && error [ 'code' ] == 'auth/credential-already-in-use' ) {
103
+ } else if ( normalizedError &&
104
+ normalizedError [ 'code' ] == 'auth/credential-already-in-use' ) {
98
105
// Do nothing and keep callback UI while onUpgradeError catches and
99
106
// 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 ) ) {
103
112
// Operation is not supported in this environment but only password
104
113
// provider is enabled. So allow this to proceed as a no redirect result.
105
114
// This will allow developers using password sign-in in Cordova to use
@@ -114,7 +123,7 @@ firebaseui.auth.widget.handler.handleCallback =
114
123
} else {
115
124
// Go to the sign-in page with info bar error.
116
125
firebaseui . auth . widget . handler . handleCallbackFailure_ (
117
- app , component , /** @type {!Error } */ ( error ) ) ;
126
+ app , component , /** @type {!Error } */ ( normalizedError ) ) ;
118
127
}
119
128
} ) ) ;
120
129
} ;
0 commit comments