public ActionResult Logout() { try { SessionId sessionId = new SessionId(HttpContext.Session.SessionID); UserContext.Logout(); return Json(new { result = "Redirect", url = Url.Action("", "") }); } catch (AutenticationException ex) { return Json(new { result = "Error", message = ex.Message }); } }
public ActionResult Login(string username, string password) { try { SessionId sessionId = new SessionId(HttpContext.Session.SessionID); Tiskarna.TiskarnaVosahlo.Autentication.LogIn(sessionId, username, password); return Json(new { result = "Redirect", url = Url.Action("Home", "Home") }); } catch (AutenticationException ex) { return Json(new { result = "Error", message = ex.Message }); } }
public void LogIn(SessionId sessionId, String username, String password) { try { IUser user = GetUser(username, password); IRights rights = GetRights(user); if (UserContext.SessionId != SessionId.Empty) { UserContext.Logout(); } UserContext.Login(sessionId, user, rights); } catch (Exception) { UserContext.Logout(); throw; } }