Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

Rewriting WebForms/SQL Membership to MVC/ASP.NET Identity - Authenticate pre-existing users

$
0
0

I am starting over, rewriting an existing webforms website. The new build started using the MVC WebApp template (with identity) created by Visual Studio 2017. I am trying to implement a similar technique outlined by Travis Nelson where you authenticate the existing SQL Membership users in the Identity framework.
See here http://travis.io/blog/2015/03/24/migrate-from-aspnet-membership-to-aspnet-identity/

The article shows how to add the migration to a webforms project not the mvc web app template created by Visual Studio 2017.
I am stuck trying to add/implement his use of the SqlPasswordHasher class he created and get it (or something similar) to work in MVC WebApp template created by Visual Studio 2017.

I have been puzzled looking at the following places in the MVC template trying to figure out how I can implement the SqlPasswordHasher class.

AccountController.cs
// This doesn't count login failures towards account lockout
// To enable password failures to trigger account lockout, change to shouldLockout: true
var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: true);
switch (result)
{
case SignInStatus.Success:
return RedirectToLocal(returnUrl);
case SignInStatus.LockedOut:
return View("Lockout");
case SignInStatus.RequiresVerification:
return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
case SignInStatus.Failure:
default:
ModelState.AddModelError("", "Invalid login attempt.");
return View(model);
}

IdentityModels.cs
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("DefaultConnection", throwIfV1Schema: false)
{
}

public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}

How can I do this? Or where do I begin?

Thank you very much for reading this and attempting to assist!


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>