c# - how to update a username in simplemembership? -


I am creating an MVC4 application Email address as the user's username I have a situation where the user Email address can change, which means that I need a system to be able to change my username.

Is it possible that MVC 4 and with simplicity?

So I want to convert an existing user name to a new one

thanks

The Simple Subscription WebSecurity API does not provide ways to update a user. To do this, you have to use the entity framework

The option one is to use that provides an extended implementation of WebSecurity. Here is a snippet from a unit test in a simple security project that tests the user updating, where the user name is modified.

  [TestMethod] Public Zero TestUpdateUser () {string username = "jdoe"; String password = "password"; String Token = Web Security. Creteuseor andaccount (username, password, "jdoe@gmail.com", incorrect); Bool validated = WebSecurity.ValidateUser (username, password); Assign Truth (valid, "user's unsuccessful recognition."); // Update user for user = WebSecurity.GetUser (username); // username change name = "jdoe2"; User.UserName = Username; // Update user information WebSecurity.UpdateUser (user); // Make sure we can still validate them = WebSecurity.ValidateUser (username, password); Confirm. Truth (valid, "failure of user to verify after update."); }  

The second option is to see the source code in SimpleSecurity to see how it was implemented and to replicate it. You can do this . You can step through the unit test in SimpleSecurity.UnitTest .


Comments