public override void OnActionExecuting(ActionExecutingContext filterContext) { var request = filterContext.HttpContext.Request; if (!AuthorizedInfo.IsAuthorized()) { return; } base.OnActionExecuting(filterContext); }
// GET: Header public ActionResult GetHeader() { if (Tools.AuthorizedInfo.IsAuthorized()) { string str = AuthorizedInfo.getAuthorized().first_name + AuthorizedInfo.getAuthorized().last_name + " is authorized"; return(PartialView("~/Views/Shared/Login.cshtml", str)); } else { return(PartialView("~/Views/Header/GetHeader.cshtml")); } }
public ActionResult Login(string login, string password) { // поиск пользователя в бд Customer user = null; homeRepo.OpenConnection(connection_str); user = homeRepo.getAuthorizedClient(login: login, password: password); homeRepo.CloseConnection(); if (user != null) { FormsAuthentication.SetAuthCookie(user.first_name + user.last_name, true); AuthorizedInfo.setAuthorized(user); string response = user.first_name + user.last_name + " is authorized"; ViewBag.customer_id = user.customer_id; //return RedirectToAction("BooksOnHand", "Customer", new { customer_id = user.customer_id }); return(PartialView(model: response)); } else { // return RedirectToRoute("Default"); return(PartialView(model: login + "is not authorized")); } }