Take the community feedback survey now.
Take the community feedback survey now.
 
                If you didn't delete the old user tables, then you can use the old membership provider to try a login, if that is a success, then you can update the password on with the identity provider.
The way I did this task was it is:
Something like
[HttpPost]
public async Task<ActionResult> InternalLogin(LoginViewModel viewModel)
{
    var result = await SignInManager.PasswordSignInAsync(viewModel.Email, viewModel.Password, viewModel.RememberMe, shouldLockout: true);
    switch (result)
    {
        case SignInStatus.Success:
            break
        case SignInStatus.LockedOut:
            return PartialView("~/Views/Features/Login/_lockout.cshtml", viewModel)
        case SignInStatus.RequiresVerification:
            return RedirectToAction("SendCode", "Login", new { ReturnUrl = viewModel.ReturnUrl, RememberMe = viewModel.RememberMe })
        default:
            return await UpdatePasswordFromOldSystem(viewModel);
    
    return Json(new { ReturnUrl = returnUrl });
}
public async Task<ActionResult> UpdatePasswordFromOldSystem(LoginViewModel viewModel)
{
    // the password was correct, but it wasn't in new system, update it
    if (Membership.ValidateUser(viewModel.Email, viewModel.Password))
    {
        UserManager.PasswordValidator = new PasswordValidator() // turn off validating requirements
        {
            RequiredLength = 0,
            RequireNonLetterOrDigit = false,
            RequireDigit = false,
            RequireLowercase = false,
            RequireUppercase = false
        };
        SiteUser user = await UserManager.FindByNameAsync(viewModel.Email); // get the user
        string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id); // get reset token
        IdentityResult reset = await UserManager.ResetPasswordAsync(user.Id, code, viewModel.Password); // reset the password with the password the user used and token we got
        if (reset.Succeeded) // if it succeeded, then try login again
        {
            return await InternalLogin(viewModel);
        }
    }
    
    // wrong username/password, show error
    ModelState.AddModelError("Password", _localizationService.GetString(() => Translations.Login.WrongPasswordOrEmail));
    viewModel.Password = null;
    return PartialView("~/Views/Features/Login/_login.cshtml", viewModel);
}
Remember to change password on the old provider too when a user change password :) (I know this is a litle hacky way, but it works for me at least :))
Oh, and this is the migration script i ran (after deployment so the tables get made)
INSERT INTO AspNetUsers(
                Id,
                Email,
                EmailConfirmed,
                PasswordHash,
                SecurityStamp,
                PhoneNumberConfirmed,
                TwoFactorEnabled,
                LockoutEnabled,
                AccessFailedCount,
                UserName,
                NewsLetter,
                IsApproved,
                IsLockedOut,
                Comment,
                CreationDate,
                LastLoginDate
)
SELECT 
aspnet_Users.UserId,
aspnet_Membership.Email,
1,
('AFPMQQQEExOuGGdX/PYqosGS4johxSt7NycCbbxRG/VtYAywHKYeNR5genTrTdOB7g=='),
'0b039082-4d6d-4fab-b36b-01492e58e9c4',
0,
0,
0,
0,
aspnet_Users.UserName,
0,
1,
0,
aspnet_Membership.Comment,
ISNULL(aspnet_Membership.CreateDate, GETDATE()),
aspnet_Membership.LastLoginDate
FROM aspnet_Users
LEFT OUTER JOIN aspnet_Membership ON aspnet_Membership.ApplicationId = aspnet_Users.ApplicationId 
AND aspnet_Users.UserId = aspnet_Membership.UserId;
INSERT INTO AspNetRoles(Id,Name)
SELECT RoleId,RoleName
FROM aspnet_Roles;
INSERT INTO AspNetUserRoles(UserId,RoleId)
SELECT UserId,RoleId
FROM aspnet_UsersInRoles;
                        try this version for SQL Password hasher https://stackoverflow.com/questions/46074408/migration-of-asp-net-membership-to-mvc-net-identity-password-issue
Thanks for the suggestions guys, they're all good but after finally getting a lot of sleep this weekend I resolved this issue, I had made a stupid mistake in my LoginController in which I was calling the ApplicationUserManager instead of my CustomUserManager, therefore the users were never getting to my passwordhasher.
 
    
    
    
Hello,
I'm migrating our newly updated CMS10/Commerce website from using the old .net Membership references to Episerver's aspnetidentity.
I followed the directions on this page, and all seemed to work well:
http://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/9/Security/episerver-aspnetidentity/
Next, I successfully ran a script that imported all our users from the old membership tables to the new aspnet identity tables.
Whenever I try to log on using an old login I get the following error:
After some searching, I tried implementing the following fix: http://sveinaandahl.blogspot.se/2016/03/how-to-validate-old-passwords-when.html
I added a UserManager Class:
And then I modified my StartUp.cs:
But it appears to have no effect, I still receive the same error every time. Has anyone dealt with this or fixed this that can help?
Thanks!
John