public ActionResult Login(string email, string password) { var db = new AuthDb(Properties.Settings.Default.ConStr); var user = db.Login(email, password); if (user == null) { return(RedirectToAction("Login")); } FormsAuthentication.SetAuthCookie(email, true); return(RedirectToAction("Index", "Home")); }
public ActionResult LogIn(string email, string password) { var db = new AuthDb(Properties.Settings.Default.ConStr); var user = db.Login(email, password); if (user == null) { TempData["message"] = "Invalid login attempt"; return(Redirect("/account/login")); } FormsAuthentication.SetAuthCookie(email, true); return(Redirect("/")); }
public IActionResult Login(string email, string password) { var db = new AuthDb(_connectionString); var user = db.Login(email, password); if (user == null) { return(RedirectToAction("Login")); } //this code is conceptually the same as FormsAuthentication.SetAuthCookie() var claims = new List <Claim> { new Claim("user", email) }; HttpContext.SignInAsync(new ClaimsPrincipal( new ClaimsIdentity(claims, "Cookies", "user", "role"))).Wait(); return(Redirect("/home/about")); }