0

So, I am creating a simple registration - login screen app, for android, using Kotlin and Firebase. The user should be able to register, by providing his email address, a username and a password. If the email and username are not being used already, the user should be able to login, using his username and password

The problem I am facing is, I cannot understand how to save the username and use it for authentication. I thought of using the createUserWithEmailAndPassword function as shown below.

suspend fun registerUser(email: String, password: String) {
    response = MutableLiveData()
    try {
        auth.createUserWithEmailAndPassword(email, password).await()
        response.value = "Succeed"
    } catch (e: Exception) {
        response.value = e.message
    }
}

If the user manages to register, I'll then use the currentUser function, to save his username

Thing is, I am stuck on where to go from there (if that is even the way to go). The documentation did not help all that much, so any detailed answer would help

Thanks

Fotis
  • 15
  • 6
  • This has been asked many times before, so I recommend searching for [Firebase auth using username instead of email](https://www.google.com/search?q=site:stackoverflow.com+Firebase+auth+using+username+instead+of+email) and implementing what has been recommended there. If you tried to do this and ran into problems, edit your question to show a [minimal repro](http://stackoverflow.com/help/mcve) of where you got stuck. – Frank van Puffelen Sep 19 '22 at 02:54

1 Answers1

1

At this moment (Sept 2022), username & password sign-in is not supported natively in Firebase Auth.

Some alternative ways:

  • implement a custom provider as shown in this example.
  • mapping <username> to <username>@yourowndomain.com
  • use custom token in this document
user16806454
  • 391
  • 3
  • 8