Skip to content

Adds error handling in the signin handler when fetchProvidersForEmail… #123

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 3 commits into from
Apr 4, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 8 additions & 1 deletion javascript/widgets/handler/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,14 @@ firebaseui.auth.widget.handler.common.handleStartEmailFirstFlow =
undefined,
opt_infoBarMessage);
},
function(error) {}
function(error) {
// The email provided could be an invalid one or some other error
// could occur.
var errorMessage =
firebaseui.auth.widget.handler.common.getErrorMessage(
error);
component.showInfoBar(errorMessage);
}
));
};

Expand Down
36 changes: 36 additions & 0 deletions javascript/widgets/handler/signin_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,42 @@ function testHandleSignIn() {
}


function testHandleSignIn_accountLookupError() {
// Test when account lookup throws an error.
var expectedError = {
'code': 'auth/invalid-email',
'message': 'The email address is badly formatted.'
};
app.updateConfig('signInOptions', signInOptionsWithScopes);
firebaseui.auth.widget.handler.handleSignIn(app, container);
assertSignInPage();

// Now email input has 'user', which is not a valid email address.
var emailInput = getEmailElement();
// Pass an invalid email that will pass client side validation.
goog.dom.forms.setValue(emailInput, '[email protected]');
goog.testing.events.fireKeySequence(emailInput, goog.events.KeyCodes.ENTER);
assertSignInPage();

// Enter key triggers fetchProvidersForEmail.
goog.testing.events.fireKeySequence(emailInput, goog.events.KeyCodes.ENTER);

testAuth.assertFetchProvidersForEmail(
['[email protected]'],
null,
expectedError);
return testAuth.process().then(function() {
// Should remain on the same page.
assertSignInPage();
// Account should not be remembered.
assertFalse(firebaseui.auth.storage.isRememberAccount(app.getAppId()));
// Error message should be displayed in the info bar.
assertInfoBarMessage(
firebaseui.auth.widget.handler.common.getErrorMessage(expectedError));
});
}


function testHandleSignIn_reset() {
// Test when reset is called after sign-in handler called.
firebaseui.auth.widget.handler.handleSignIn(app, container);
Expand Down