Closed alfred-mikhael closed 1 year ago
I think it feels more right to have usernames be unique. If this were a real app, I think i would forget my own id number pretty quickly.
Would it be better to have the login username or email be unique, and maybe have a separate display name? It would be like discord or skype, where you log in with an email, but you can choose a nickname
Yeah that makes sense. In order to make this easier, would it be okay to change the User documents in the database, so that they name of the document is the username rather than the user id? This would cost us less reads and overall be faster.
If the usernames end up being unique, we can definitely change the user document names to be the usernames. I also am leaning towards having the user choose a unique username. Would we want to add a displayName attribute to the User entity, as well as making a displayName field in the Firebase database for users?
That's a good idea, I can certainly make those changes. @alx672219, are you okay with this? You will have to do a little refactoring.
Then, are we changing the user IDs to be String instead of Integer?
Not exactly, in this case, we would have usernames be unique, and possibly add a separate display name. So you would add contacts via username instead of user id, but the display name would be the one shown on screen. Seeing how a lot of our code depends on the documents being named by user ID, we can keep this part the same.
Since usernames are not unique and passwords are not unique either, there can be two users with the exact same username and password. This would cause an error when signing in. I see that there are a few solutions to this:
Personally, I lean towards the third option because that allows users to have the same username and lets users have multiple accounts per email. What are your opinions?