When a user is signing up to my app, I have a condition that checks if a username is taken to prevent repeated names.
if (takenUsername == "taken") {
Toast.makeText(this@SignUp, "This username is unavailable", Toast.LENGTH_SHORT).show()
}
However, if the username is free the sign-up becomes successful and that username is then added as a taken username in the DB
else{
takenNames.child(usernameSortBy).setValue("taken")
}
the database looks like this:
name1: taken
name2: taken
name3: taken
name4: taken
The problem is that the toast message seems to apply to both cases - if it's taken then the toast appears. If it's not taken then the signup becomes successful and the toast still appears as it is NOW taken.
If sign-up is successful, I do not want that toast message to show up.
Aucun commentaire:
Enregistrer un commentaire