I am creating a web app where when you register you give input of username and password, now at first I thought I was done with the login/register system but then I realized I can create accounts with the same username as long as I add a space ( ) to the end or change a letter to capital. I want only one person to have a username no matter what the capitalization is, how can I detect these fakes? my detection code:
if(user) {
res.json({
message: "User Already Exists"
})
}
user = searching for a user in the db with the input but it doesn't have any other detection!
I though of adding a "pronunciation" to the db info so it would be all lower case to prevent capital letter abuse but that seems unnecessary, also how can I detect spaces ( )?
.trim
to prevent whitespace at the start/end of the string