public async Task <ActionResult> SignInAs(int id) { var user = await GetCompanyUser(id); //var userManager = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>(); var authenticationManager = HttpContext.GetOwinContext().Authentication; ClaimsIdentity identity = new ClaimsIdentity(DefaultAuthenticationTypes.ApplicationCookie); identity.AddClaimsForUser(user, CompanyRole); authenticationManager.SignIn(identity); if (Session["ReturnToAdminRole"] == null) { Session["ReturnToAdminRole"] = true; } return(RedirectToAction("Details", "Business", new { id })); }
public static void AddClaimsForUser(this ClaimsIdentity identity, ApplicationUser user, string role) { identity.AddClaim(new Claim(ClaimTypes.Role, role)); identity.AddClaimsForUser(user); }