Skip to content

Commit

Permalink
Fixes issue when email link user tries to sign in with FirebaseUI whe…
Browse files Browse the repository at this point in the history
…n only email/password sign in method is provided. (#710)

In this case, we should just fallback to unsupported provider screen.
  • Loading branch information
bojeil-google authored May 26, 2020
1 parent 6067268 commit 7404a41
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 13 deletions.
36 changes: 23 additions & 13 deletions javascript/widgets/handler/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1417,19 +1417,29 @@ firebaseui.auth.widget.handler.common.handleSignInFetchSignInMethodsForEmail =
opt_displayFullTosPpMessage);
} else if ((signInMethods.length == 1) && (signInMethods[0] ===
firebase.auth.EmailAuthProvider.EMAIL_LINK_SIGN_IN_METHOD)) {
// Existing email link account.
firebaseui.auth.widget.handler.handle(
firebaseui.auth.widget.HandlerName.SEND_EMAIL_LINK_FOR_SIGN_IN,
app,
container,
email,
function() {
// Clicking back button goes back to sign in page.
firebaseui.auth.widget.handler.handle(
firebaseui.auth.widget.HandlerName.SIGN_IN,
app,
container);
});
if (app.getConfig().isEmailLinkSignInAllowed()) {
// Existing email link account.
firebaseui.auth.widget.handler.handle(
firebaseui.auth.widget.HandlerName.SEND_EMAIL_LINK_FOR_SIGN_IN,
app,
container,
email,
function() {
// Clicking back button goes back to sign in page.
firebaseui.auth.widget.handler.handle(
firebaseui.auth.widget.HandlerName.SIGN_IN,
app,
container);
});
} else {
// Email link sign-in is the only option for this user but it is not
// supported in the current app configuration.
firebaseui.auth.widget.handler.handle(
firebaseui.auth.widget.HandlerName.UNSUPPORTED_PROVIDER,
app,
container,
email);
}
} else {
// Federated Account.
// The account exists, and is a federated identity account.
Expand Down
16 changes: 16 additions & 0 deletions javascript/widgets/handler/common_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1925,6 +1925,22 @@ function testHandleSignInWithEmail_prefillEmail() {
}


function testHandleSignInFetchSignInMethodsForEmail_unsupportedProvider() {
// When user has previously signed in with email link but only email/password
// auth is supported in the app's configuration.
var signInMethods = ['emailLink'];
var email = '[email protected]';
app.updateConfig('signInOptions', [{'provider': 'password'}]);
firebaseui.auth.widget.handler.common.handleSignInFetchSignInMethodsForEmail(
app, container, signInMethods, email);
// It should not store pending email.
assertFalse(firebaseui.auth.storage.hasPendingEmailCredential(
app.getAppId()));
// Unsupported provider page should show.
assertUnsupportedProviderPage(email);
}


function testLoadAccountchooserJs_externallyLoaded() {
// Test accountchooser.com client loading when already loaded.
// Reset loadAccountchooserJs stubs.
Expand Down

0 comments on commit 7404a41

Please sign in to comment.