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

Support for username authentication #580

Closed anvarik closed 1 year ago

anvarik commented 5 years ago

It's been years and still, Firebase won't support username authentication... Any chance to consider this at some point?

In the interim what would be a good and secure approach to pass usernames along with Firebase's email authentication?

I feel like if we can configure the display name and change the label without modifying firebaseui code, and can enforce the display name to be unique that would solve my problem. I just wanted to get some feedback on what community thinks about these options, any examples are welcome.

bojeil-google commented 5 years ago

FirebaseUI is unlikely to support username / password until it is supported in the underlying firebase-auth library. You will need to build that on your own. I have seen multiple approaches online for this.

  1. Using realtime database or Firestore to store a mapping from username to email. When a user enters their username, you get the corresponding email and signInWithEmailAndPassword.
  2. Another approach is to add a dummy domain name to the username username@my-project-id.firebaseapp.com and then call signInWithEmailAndPassword. The downside is that there will not be a recovery email for the user.

You can learn more about this on stackoverflow. In general, I don't recommend usernames as you will always need to ask the user for their email for recovery purposes (if you forget your password with username sign-in then your account is lost) and to verify identities if needed. So you will end up asking the user for both a username and an email.

cargallo commented 4 years ago

The explanation given has no sense. There are lot of applications that manages users login with both alternatives at the same time, username or email login.

dbacinski commented 3 years ago

We have a use case of migrating WordPress users to Firebase. WordPress both support authentication with email and username, but Firebase just offers emails, which can be a "deal-breaker".

annzimmer commented 3 years ago

We don’t support this out of the box because 1. it would be more susceptible to abuse than using, for example, a trusted email provider or any of the OAuth2 providers and 2. the password recovery flow would be broken without an email for each user.

If you really need only usernames, could probably implement this using signInWithCustomToken, but make sure you have a solution for the two problems above.

jhuleatt commented 1 year ago

This is not something FirebaseUI can support unless it is implemented in the underlying product, Firebase Authentication. To file a feature request for Firebase Authentication, please post here: https://firebase.uservoice.com/forums/948424-general?category_id=464875