in javascript/widgets/handler/callback.js [46:143]
function(app, container, opt_result) {
// Render the UI.
var component = new firebaseui.auth.ui.page.Callback();
component.render(container);
// Set current UI component.
app.setCurrentComponent(component);
// Get result either from passed result or from app's getRedirectResult.
var resultObtainer = opt_result || app.getRedirectResult();
app.registerPending(resultObtainer.then(function(result) {
firebaseui.auth.widget.handler.handleCallbackResult_(app, component,
result);
}, function(error) {
// Normalize the error.
const normalizedError =
firebaseui.auth.widget.handler.common.normalizeError(error);
// A previous redirect operation was triggered and some error occurred.
// Test for need confirmation error and handle appropriately.
// For all other errors, display info bar and show sign in screen.
if (normalizedError &&
// Single out need confirmation error as email-already-in-use and
// credential-already-in-use will also return email and credential
// and need to be handled differently.
(normalizedError['code'] ==
'auth/account-exists-with-different-credential' ||
normalizedError['code'] == 'auth/email-already-in-use') &&
normalizedError['email'] &&
normalizedError['credential']) {
// Save pending email credential.
firebaseui.auth.storage.setPendingEmailCredential(
new firebaseui.auth.PendingEmailCredential(
normalizedError['email'], normalizedError['credential']),
app.getAppId());
firebaseui.auth.widget.handler.handleCallbackLinking_(
app, component, normalizedError['email']);
} else if (normalizedError &&
normalizedError['code'] == 'auth/user-cancelled') {
// Should go back to the previous linking screen. A pending email
// should be present, otherwise there's an error.
const pendingCredential =
firebaseui.auth.storage.getPendingEmailCredential(app.getAppId());
const message =
firebaseui.auth.widget.handler.common.getErrorMessage(
normalizedError);
// If there is a credential too, then the previous screen was federated
// linking so we process the error as a linking flow.
if (pendingCredential && pendingCredential.getCredential()) {
firebaseui.auth.widget.handler.handleCallbackLinking_(
app, component, pendingCredential.getEmail(), message);
// Otherwise, the user had entered his email but a federated account
// already existed. It had then triggered federated sign in, but the user
// did not consent to the scopes. It then needs to restart the federated
// sign in flow.
} else if (pendingCredential) {
firebaseui.auth.widget.handler.common.handleStartEmailFirstFlow(
app, component, pendingCredential.getEmail(), message);
} else {
// Go to the sign-in page with info bar error.
firebaseui.auth.widget.handler.handleCallbackFailure_(
app, component, /** @type {!Error} */ (normalizedError));
}
} else if (normalizedError &&
normalizedError['code'] == 'auth/credential-already-in-use') {
// Do nothing and keep callback UI while onUpgradeError catches and
// handles this error.
} else if (normalizedError &&
normalizedError['code'] ==
'auth/operation-not-supported-in-this-environment' &&
firebaseui.auth.widget.handler.common.isPasswordProviderOnly(
app)) {
// Operation is not supported in this environment but only password
// provider is enabled. So allow this to proceed as a no redirect result.
// This will allow developers using password sign-in in Cordova to use
// FirebaseUI.
firebaseui.auth.widget.handler.handleCallbackResult_(
app,
component,
{
'user': null,
'credential': null
});
} else if (normalizedError &&
normalizedError['code'] == 'auth/admin-restricted-operation' &&
app.getConfig().isAdminRestrictedOperationConfigured()) {
component.dispose();
firebaseui.auth.storage.removePendingEmailCredential(app.getAppId());
firebaseui.auth.widget.handler.handle(
firebaseui.auth.widget.HandlerName.UNAUTHORIZED_USER,
app,
container,
null,
null);
} else {
// Go to the sign-in page with info bar error.
firebaseui.auth.widget.handler.handleCallbackFailure_(
app, component, /** @type {!Error} */ (normalizedError));
}
}));
};