Skip to content

Instantly share code, notes, and snippets.

@JohannesSundqvist
Created October 10, 2016 07:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohannesSundqvist/1ef5cceb8a097901b4103b2147d0a54d to your computer and use it in GitHub Desktop.
Save JohannesSundqvist/1ef5cceb8a097901b4103b2147d0a54d to your computer and use it in GitHub Desktop.
public ActionResult CheckLogin() {
if (HttpContext.Request.Cookies["LoginCookie"] == null)
{
return RedirectToAction("Login", "Main");
}
else
{
return View();
}
}
public IActionResult Login() {
// .. if login is successful
HttpContext.Response.Cookies.Append("LoginCookie", "LoginIsValid");
}
public IActionResult MainPage() {
CheckLogin();
return View();
}
public IActionResult Logout() {
HttpContext.Response.Cookies.Delete("LoginCookie");
}
Expected: As I enter MainPage, I should be redirected to the Login page.
Actual: As I enter MainPage, I get full access.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment