-
-
Save JohannesSundqvist/1ef5cceb8a097901b4103b2147d0a54d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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