Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC4 : What entity represents table webpages_Membership

I'm trying to access webpages_Membership table (I'm using SimpleMembership) to retrieve the account ConfirmationToken.

How do I access this table from my model/controller/DAL?

The only thing I can think of is executing pure SQL from my code to get this value, but that's doesn't seem like it's the right thing to do, nor elegant.

like image 411
9999bao Avatar asked Sep 23 '12 05:09

9999bao


1 Answers

From what I understand, there's no direct way to retrieve the value using WebSecurity helper.

When you create a User and Account the method returns the confirmation token:

string confirmationToken = WebSecurity.CreateUserAndAccount("tester", "test123", requireConfirmationToken: true);

You then send this token (inside a link as a QueryString parameter for example) to the User's e-mail address. When the user clicks the link, your app must get/read this token and then you must call:

WebSecurity.ConfirmAccount(userName, confirmationToken);

As you mentioned you can of course hit the db directly writing your own SQL or even add the webpages_Membership to an EntityFramewok EDMX model and query the table directly:

var confirmationToken = Database.Memberships.Single(m => m.UserId == userId).ConfirmationToken;

More on this:

Using the confirmation feature for ASP.NET Web Pages security

Get Account Confirmation Token?

like image 160
Leniel Maccaferri Avatar answered Oct 26 '22 10:10

Leniel Maccaferri