public ActionResult Login(Account user) { AccountsPracownikOb acc = new AccountsPracownikOb(); if (string.IsNullOrEmpty(user.Login) || string.IsNullOrEmpty(user.Haslo) || acc.login(user.Login, user.Haslo) == null) { ViewData["Msg"] = "true"; return(View("Index")); } else { ViewData["Msg"] = "false"; SessionPersiter.Username = user.Login; return(RedirectToAction("ListaWizyt")); } }
public override void OnAuthorization(AuthorizationContext filterContext) { if (string.IsNullOrEmpty(SessionPersiter.Username)) { filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary(new { controller = "PanelPracownika", action = "Index" })); } else { AccountsPracownikOb apo = new AccountsPracownikOb(); CustomPrincipal cp = new CustomPrincipal(apo.find(SessionPersiter.Username)); if (!cp.IsInRole(Roles)) { filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary(new { controller = "Home", action = "Index" })); } } }