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 "Bob@mail.com"?
Is this possible with Firebase?
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 "Bob@mail.com"?
Is this possible with Firebase?
Simple: you can 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.
If this doesn't suit your needs, you can roll your own 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.
You can use firebase custom auth. Custom auth is a method which user can login into app using custom token.
But, you need backend code, to create custom token when user send username and password to that backend.
Fortunately, now there is firebase cloud function, with http event, that can solve your problem easily. The step is :
User send username and password to cloud function url via query params (GET) or request body (POST)
Cloud funtion will check whether username and password is valid (ex: from realtime database)
If the username and password valid, cloud function will create custom token using userId (you need to save the userId). And then send it to response body
Client then can login using that customToken
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: