DEV Community

Michael Akanji
Michael Akanji

Posted on

How can I reserve/protect/disable certain keywords in applications?

Hello there,

Firstly; thanks for showing up here.

I am developing a web application. So I would like to learn/hear from you on how I can protect, reserve, restrict and/or disable some keywords from being used by users as their username of choice.

i.e When a user choose to use Administrator as his/her username. They should get an error saying, the username is not available only because I have added the word Administrator as a reserved word on the server.

Now the last part of my question is; What happens in a case I forgot to reserve a word and a user was able to choose it as their username of choice. What is the next thing to do in this case?

Thanks in anticipation of your responses.

Top comments (1)

Collapse
 
avalander profile image
Avalander • Edited

The first part should be straightforward. Simply store the list of blacklisted words somewhere and when the server receives the sign up request, it checks the user name against that list and sends and error if it finds it.

Blacklisting a username that someone has already taken is a bit more tricky. I guess if it is really important you can always send them an email explaining the situation, asking them to change the username and giving a deadline when you are going to automatically change the username. Something like dear user Administrator. Due to a change in our policy, your username is not valid anymore. Please visit the following link to change it. Note that if you don't update your username within a week, the system will automatically change it to "User_01738". Thanks for your understanding.

You should keep in mind that if you are using the username to identify the user across the application it will be a lot harder to change it, therefore I recommend that you identify the user with a generated key and just use the username for display purposes.