Skip to content

Instantly share code, notes, and snippets.

@DmitrySikorsky
Last active August 3, 2017 09:18
Show Gist options
  • Save DmitrySikorsky/e474850b0ff84ef39d681b439fbc178e to your computer and use it in GitHub Desktop.
Save DmitrySikorsky/e474850b0ff84ef39d681b439fbc178e to your computer and use it in GitHub Desktop.
public class HomeController : Controller
{
private IUserManager userManager;
public HomeController(IUserManager userManager)
{
this.userManager = userManager;
}
[HttpGet]
public IActionResult Index()
{
return this.View();
}
[HttpPost]
public IActionResult Login()
{
User user = this.userManager.Validate("Email", "[email protected]", "admin");
if (user != null)
this.userManager.SignIn(this.HttpContext, user, false);
return this.RedirectToAction("Index");
}
[HttpPost]
public IActionResult Logout()
{
this.userManager.SignOut(this.HttpContext);
return this.RedirectToAction("Index");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment