User Verification in SimpleMembership

What is the alternative to Membership.ValidateUser () in SimpleMembership? I use WebSecurity.Login to verify the current user, but I have a situation where the user re-enters his password to change some user settings. Should I just use WebSecurity.Login again? It seems like a bust.

+4
source share
1 answer

I also needed to just check the user in SimpleMembership, and I think I found a suitable solution. You just need to grab the membership provider and call the method from there. Here is how I did it.

 public static bool ValidateUser(string userName, string password) { var membership = (WebMatrix.WebData.SimpleMembershipProvider)Membership.Provider; return membership.ValidateUser(userName, password); } 

I created a unit test for this and verified that it works. You can get a list of methods available for this membership provider here .

I added this to the SimpleSecurity open source project, which discusses ways to extend SimpleMembership and provides examples of using SimpleMembership. It also separates SimpleMembership from your MVC application .

+8
source

Source: https://habr.com/ru/post/1502843/


All Articles