public async Task <ActionResult> Login(LoginViewModel model, string returnUrl) { if (!ModelState.IsValid) { return(View(model)); } string errorMessage = "Unexpected Login failure. Please try again."; DarkLoginSession s = Session["DarkLoginSession"] as DarkLoginSession; switch (s.Authenticate(model.Username, model.Password)) { case AuthenticationResult.Success: { return(RedirectToLocal(returnUrl)); } case AuthenticationResult.InvalidSession: { errorMessage = "You are already logged into this website from this device. Ensure that you have logged out, and wait a few minutes before trying again."; break; } case AuthenticationResult.InvalidLogin: { errorMessage = "The username and password combination do not match. Please try again."; break; } } ModelState.AddModelError("", errorMessage); return(View(model)); }
public ActionResult Logoff() { DarkLoginSession s = Session["DarkLoginSession"] as DarkLoginSession; s.Logoff(); return(RedirectToAction("Index", "Home")); }
protected void Session_End() { DarkLoginSession s = Session["DarkLoginSession"] as DarkLoginSession; s.Logoff(); }