How to provide user login with a username and NOT an email?

Steve Lee picture Steve Lee · May 26, 2016 · Viewed 29.2k times · Source

I'd like to use Firebase for my web app that is for people with dementia in a care home. They do not have email or social network accounts so will need a simple username / password sign up / sign in.

What is the easiest way to do this? From what I can see in the docs I'd have to use a custom auth flow but I do not have an existing auth server.

If I do need ot do this what is the easiest way to provide the token? In Azure there is Functions and AWS has Lambda but I see nothing here is Firebase

Answer

Alfonso Gomez Jordana Manas picture Alfonso Gomez Jordana Manas · May 27, 2016

You are correct that username/password sign-in is not supported natively in Firebase Auth at this moment.

You can implement a custom provider as shown in this example. This allows you to meet any custom requirements, but is admittedly a bit more involved than using the built-in providers. There is an example of this here that you can use as a starting point.

A workaround you could take without needing to use custom auth with another backend is to accept usernames in your UI, but on the underlying logic, append "@yourowndomain.com" before calling the functions to sign up or sign in with email.

So you would be using email/password authentication, mapping <username> to <username>@yourowndomain.com