views:

324

answers:

3

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 admin 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 do this or do i have to code it up from scratch using my own implementation.

i have a few ideas and i dont think this is rocket science but i dont want to reinvent the wheel as i want to ship this asap.

+2  A: 

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.

Stilgar
how do i have a screen for the admin to review users who are not approved? is there an example
ooo
I don't know of an example but you can get all users filter them before showing them to the admin. Unless you have more than a thousand users there should be no problem. If you have more you will probably need to implement your own method.As blowdart mentioned there is no straight forward way.
Stilgar
A: 

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".

blowdart
+2  A: 

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); }

saille
what would the view class look like in this case?
ooo