Skip to content

Commit 7404a41

Browse files
Fixes issue when email link user tries to sign in with FirebaseUI when only email/password sign in method is provided. (firebase#710)
In this case, we should just fallback to unsupported provider screen.
1 parent 6067268 commit 7404a41

File tree

2 files changed

+39
-13
lines changed

2 files changed

+39
-13
lines changed

javascript/widgets/handler/common.js

+23-13
Original file line numberDiff line numberDiff line change
@@ -1417,19 +1417,29 @@ firebaseui.auth.widget.handler.common.handleSignInFetchSignInMethodsForEmail =
14171417
opt_displayFullTosPpMessage);
14181418
} else if ((signInMethods.length == 1) && (signInMethods[0] ===
14191419
firebase.auth.EmailAuthProvider.EMAIL_LINK_SIGN_IN_METHOD)) {
1420-
// Existing email link account.
1421-
firebaseui.auth.widget.handler.handle(
1422-
firebaseui.auth.widget.HandlerName.SEND_EMAIL_LINK_FOR_SIGN_IN,
1423-
app,
1424-
container,
1425-
email,
1426-
function() {
1427-
// Clicking back button goes back to sign in page.
1428-
firebaseui.auth.widget.handler.handle(
1429-
firebaseui.auth.widget.HandlerName.SIGN_IN,
1430-
app,
1431-
container);
1432-
});
1420+
if (app.getConfig().isEmailLinkSignInAllowed()) {
1421+
// Existing email link account.
1422+
firebaseui.auth.widget.handler.handle(
1423+
firebaseui.auth.widget.HandlerName.SEND_EMAIL_LINK_FOR_SIGN_IN,
1424+
app,
1425+
container,
1426+
email,
1427+
function() {
1428+
// Clicking back button goes back to sign in page.
1429+
firebaseui.auth.widget.handler.handle(
1430+
firebaseui.auth.widget.HandlerName.SIGN_IN,
1431+
app,
1432+
container);
1433+
});
1434+
} else {
1435+
// Email link sign-in is the only option for this user but it is not
1436+
// supported in the current app configuration.
1437+
firebaseui.auth.widget.handler.handle(
1438+
firebaseui.auth.widget.HandlerName.UNSUPPORTED_PROVIDER,
1439+
app,
1440+
container,
1441+
email);
1442+
}
14331443
} else {
14341444
// Federated Account.
14351445
// The account exists, and is a federated identity account.

javascript/widgets/handler/common_test.js

+16
Original file line numberDiff line numberDiff line change
@@ -1925,6 +1925,22 @@ function testHandleSignInWithEmail_prefillEmail() {
19251925
}
19261926

19271927

1928+
function testHandleSignInFetchSignInMethodsForEmail_unsupportedProvider() {
1929+
// When user has previously signed in with email link but only email/password
1930+
// auth is supported in the app's configuration.
1931+
var signInMethods = ['emailLink'];
1932+
var email = '[email protected]';
1933+
app.updateConfig('signInOptions', [{'provider': 'password'}]);
1934+
firebaseui.auth.widget.handler.common.handleSignInFetchSignInMethodsForEmail(
1935+
app, container, signInMethods, email);
1936+
// It should not store pending email.
1937+
assertFalse(firebaseui.auth.storage.hasPendingEmailCredential(
1938+
app.getAppId()));
1939+
// Unsupported provider page should show.
1940+
assertUnsupportedProviderPage(email);
1941+
}
1942+
1943+
19281944
function testLoadAccountchooserJs_externallyLoaded() {
19291945
// Test accountchooser.com client loading when already loaded.
19301946
// Reset loadAccountchooserJs stubs.

0 commit comments

Comments
 (0)