Question

I am using the asp.net mvc sample app and have expanded it a bit. I use the asp.net membership for login and registration for users.

I now want to change it so when people register, instead of instantly being able to login, it goes to some state where an administrator has to approve it. Once this approval happens, then they can log in.

Is there anything built into asp.net membership stuff that will help me to do this or do I have to code it up from scratch using my own implementation?

I have a few ideas and I don't think this is rocket science but I don't want to reinvent the wheel as I want to ship this as soon as possible.

Was it helpful?

Solution

The MembershipUser class has an IsApproved property. You may set it to false when creating a new user and then set it to true when the admin approves the user. You have to call Membershi.UpdateUser(user) method after setting the property.

OTHER TIPS

Here's some code to build a collection of un-approved users that can be used as the datasource of a data control like a GridView, DataList, or Repeater:

MembershipUserCollection users = Membership.GetAllUsers();

MembershipUserCollection unapprovedUsers = new MembershipUserCollection();

foreach (MembershipUser u in users)
{
    if (!u.IsApproved)
        unapprovedUsers.Add(u);
}

The MembershipUser class has an IsApproved property, and during user creation you can use one of the overloads on the Membership.CreateUser function which allows that flag to be set. Unfortunately there's no easy way to say "Show me all users who are not yet validated".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top