Simeon Wislang
Simeon Wislang

Reputation: 461

ASP.NET MVC Membership Reserve

I want to be able to prevent users from registering using specific usernames such as "Admin", "Administrator" etc. Does the MVC MembershipService have a way of doing this or will I have to implement my own method to check each time a user registers?

Thanks TheLorax

Upvotes: 0

Views: 177

Answers (2)

Wyatt Barnett
Wyatt Barnett

Reputation: 15673

Robert's answer is pretty expedient if inelegant. A more elegant way would be to put some logic into the AccountController's Register method to check names against a "blacklist" then add appropriate ModelErrors if the name is blacklisted. You could also fold in other logical checks--such as verifying the user name isn't a collection of symbols, isn't profane, etc.

One could make an argument that this should really be implemented in the MembershipProvider rather than a controller and one would be pretty spot on but that is beyond the scope of this answer.

Upvotes: 1

Robert Harvey
Robert Harvey

Reputation: 180788

If it's only a handful of names, register them yourself. That will prevent anyone else from registering them.

Upvotes: 1

Related Questions