Search code examples
asp.net-mvcasp.net-mvc-4rolessimplemembership

ASP.NET MVC 4 SimpleMembershipProvider - IsConfirmed property default to false


I have default Internet Application in ASP.NET MVC 4. So I'm using SimpleMembershipProvider and I wanna make IsConfirmed property what sits in DB to false on default and then activating accounts via my own Administrator Panel. No Emails, no tokens. How Can I change that property? Maybe there's another way to do it? Should I implement my own provider?


Solution

  • When you (or your users) register a new member, modify the command call that's used: add parameter "requireConfirmationnToken: true", like this:

    WebSecurity.CreateUserAndAccount(userName, password, requireConfirmationToken: true);

    Field "IsConfirmed" will be false, and you can write a controller for your site admin to list all unconfirmed users, to either activate them or delete them.

    Note that users that authenticate using an external service like Google or Yahoo don't have an entry in the webpages_Membership table, so are active as soon as they sign on. You'd have to lock your site to members of a manually-maintained role like "activeUsers" to control everyone.