Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignInManager.PasswordSignInAsync is lying to me

I've been using this code to log in:

//
// GET: /Account/Login
[AllowAnonymous]
public ActionResult Login(string returnUrl)
{
    ViewBag.ReturnUrl = returnUrl;
    return View();
}

//
// POST: /Account/Login
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
{
    if (!ModelState.IsValid)
    {
        return View(model);
    }

    // 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: false);
    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("", Account.LoginFailure);
            return View(model);
    }
}

This is code that came with the Visual Studio MVC application template. It worked up until to day when all of the sudden it stopped working. I have debugged through this code SignInManager.PasswordSignInAsync returns Success but on the following request, I am not logged in.

Updates:

I shelved all of my pending changes and I still cannot log in. I am the only one working on this code. It is not anything I am doing.

Further Updates:

This code works on my coworkers machine. It works when I post it to the staging server. It just will not work on my computer.

like image 660
Jordan Avatar asked Apr 29 '15 13:04

Jordan


2 Answers

The first thing i did was delete "*.v12.suo" file. It didn't work. This time I first closed the solution, then deleted that file. Now it works. I can only shrug. This is a really frustrating problem. It magically works now. I hope someone can provide me with more understanding about this crazy situation.

like image 102
Jordan Avatar answered Oct 06 '22 22:10

Jordan


Even though this post is old, i just had the same problem, so in the hopes that it can help someone i will post it.

I just had a similar problem, however i didn't test online, only local. I use Chrome as primary development browser. Long story short, i found that after i cleared every possibility from my password manager (Dashlane) everything worked fine. So for me it was some weird combination of clearing everything from the site, and clearing the passwords from my password manager. Hope this helps someone in the future.

like image 40
Chimera Avatar answered Oct 06 '22 22:10

Chimera