Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Username authentication instead of email

Tags:

With Firebase I can sign up and login users using email addresses. However what if I want the app to be username based. For example, you would log in with "Bobzilla" instead of "[email protected]"?

Is this possible with Firebase?

like image 473
vikzilla Avatar asked Jan 31 '16 23:01

vikzilla


People also ask

Should I use email or username for login?

Emails Are Easier to RememberIt's easier for users to remember their email than username. This is because users check their email is regularly and type it often. It's a mistake for sites to not allow users to log in with their email. Users need to do a lot of work if they forget their username.

How do I authenticate my email address and password?

Enable Email/Password sign-in: In the Firebase console, open the Auth section. On the Sign in method tab, enable the Email/password sign-in method and click Save.

What is email link authentication?

This technique involves providing an authentication mechanism where the user can enter their email address, and they are sent an email with a link to click. When the user clicks the link in the email, they are directed back to the website and automatically logged in.


2 Answers

There is no default username+password provider built into Firebase Authentication. But you can create your own custom identity provider using the instructions in the Firebase documentation. This requires code that runs in a trusted environment, for which you can use your own server or Cloud Functions for Firebase. There is now even an example of this in the functions-samples repo.


Alternatively: you can use the built-in email+password provider and simply add any domain behind the username. So once you have determined the user name, register your user with <username>@vikzillasapp.com.

Note that this will make it impossible to for the user to reset their password if they forget it, since Firebase uses the email address to send the password reset email.

like image 59
Frank van Puffelen Avatar answered Nov 05 '22 20:11

Frank van Puffelen


Instead of using a method where you assign an email address for the user, it might be a better option to lookup an email address in your database.

An example would be:

  1. Prompt the username to login with username and password
  2. Verify the username exists in your database and retrieve the corresponding email address for that account
  3. Pass this email address to the login process seamlessly
like image 21
Scott D Avatar answered Nov 05 '22 20:11

Scott D