OdeToCode / Memflex

Brainstorming membership ideas
MIT License
71 stars 21 forks source link

FlexMemberShipProvider throws the wrong exception when try to create an account with a duplicate username #10

Closed jakejscott closed 12 years ago

jakejscott commented 12 years ago

You are throwing a generic error when trying to register with a duplicate username

throw new MembershipCreateUserException("Cannot register with a duplicate username");

https://github.com/OdeToCode/Memflex/blob/master/src/FlexProviders/Membership/FlexMembershipProvider.cs#L54

I think it should be

throw new MembershipCreateUserException(MembershipCreateStatus.DuplicateUserName);

That way when you map the validation message in the account controller it will say

"User name already exists. Please enter a different user name."

Rather than

"The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator."
OdeToCode commented 12 years ago

I think a Flex[Something] exception class would work.