firebase / firebaseui-web

FirebaseUI is an open-source JavaScript library for Web that provides simple, customizable UI bindings on top of Firebase SDKs to eliminate boilerplate code and promote best practices.
https://firebase.google.com/
Apache License 2.0
4.58k stars 1.06k forks source link

How to avoid that firebaseUI Email Link authentication opens a second browser tab? #682

Open nisserne opened 4 years ago

nisserne commented 4 years ago

When using the Email Link Authentication method with firebaseUI-web, the emailed hyperlink opens a new browser tab in order to confirm/authenticate the email reception to firebase, and then redirects to the initial URL. This leaves the user with two browser tabs with the same (authenticated) original URL.

Is there a way to end up with only one open browser tab?

I have tried to configure the firebaseUI EmailAuthProvider with an emailLinkSignIn function returning: { url: '';}, this has no effect. {url: '[another url]';}, this opens 'another url' but then does not authenticate the user (in the original browser tab). (My idea was that I could show a confirmation and guide the user to the original tab).

bojeil-google commented 4 years ago

I don't think there is any way to go back to the original tab.

nisserne commented 4 years ago
  1. So accepted normal behavior is to leave the user with two identical tabs?
  2. Any chance to configure the mentioned URL to show 'another url', and at the same time have the initial url authenticate the user? I couldn't get it to work; maybe I need to specify URL within initial domain(?).
ultraGentle commented 4 years ago

I agree that two open, logged in tabs is messy and confusing. Nevertheless, I love the potential of passwordless auth.

Here are my workarounds:

  1. You can use
    if (firebase.auth().isSignInWithEmailLink(window.location.href)) {
    // prompt user to return to original | close this tab | etc. 
    }
  2. When the original link is sent, I alert the user that they can close the current tab, and their session will resume where they left off when they click the email link.