Reputation: 827
I created a function to create a new user with the following code, which creates the user and changes their displayName:
export function handleSignup(email, password, name) {
firebase_auth.createUserWithEmailAndPassword(email, password)
.then(function(reponse) {
reponse.user.updateProfile({displayName: username});
})
.catch(function(error) {
// Handle error
});
}
The problem is that anyone can make the same username, it doesn't check for uniqueness. Is there a way for me to request a user by displayName and see if it already exists before attempting to create the new user?
Upvotes: 2
Views: 1696
Reputation: 317477
Firebase Authentication doesn't enforce uniqueness of any of its user properties. Only the assigned UID is guaranteed to be unique among all users in a project.
If you need to implement unique user names, you will have to use something else to help you with that, such as a database, and link that data to the user account using the user's UID.
Upvotes: 3