0

I have this test account that is saved in AspNetUsers (with password), AspNetRoles and AspNetUserRoles. What I want is to login this account using only the UserName (without a password).

I tried using the SignInManager.SignInAsync() but I failed when it redirects to a page with Authorize attribute, it seems that it does not authenticate the user.

public ActionResult Confirmation(string userName)
{
    var user = UserManager.FindByName(userName);
    SignInManager.SignInAsync(user, true, true);
    return RedirectToAction("Action", "Controller");
}
[Authorize(Roles = "Member")]
public ActionResult Action()
{
    // do something
}

How to do this correctly?

ekad
  • 14,436
  • 26
  • 44
  • 46
Ryan
  • 1,783
  • 8
  • 27
  • 42

1 Answers1

0

I found that these two links can solve this problem.

Community
  • 1
  • 1
Ryan
  • 1,783
  • 8
  • 27
  • 42