} // AuthorizeCore protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext) { if (filterContext.HttpContext.Request.IsAjaxRequest()) { //use code 423 for ajax request to avoid redirection by forms auth module filterContext.Result = new HttpStatusCodeResult(423); return; } // if if (IsAdminPageRedirect) { var workplaceContext = ObjectFactory.GetInstance <IEzbobWorkplaceContext>(); if (workplaceContext.User != null) { var oBrokerHelper = new BrokerHelper(); if (oBrokerHelper.IsBroker(workplaceContext.User.EMail)) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "action", "Index" }, { "controller", "BrokerHome" }, { "Area", "Broker" } }); return; } // if } // if if (this.areaName.ToString() == filterContext.RouteData.DataTokens["area"].ToString()) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "action", "AdminLogOn" }, { "controller", "Account" }, { "Area", "" }, { "ReturnUrl", filterContext.HttpContext.Request.RawUrl } }); return; } // if } // if base.HandleUnauthorizedRequest(filterContext); } // HandleUnauthorizedRequest
public override void OnActionExecuting(ActionExecutingContext filterContext) { var workplaceContext = ObjectFactory.GetInstance <IEzbobWorkplaceContext>(); if (workplaceContext.User != null) { var oBrokerHelper = new BrokerHelper(); if (oBrokerHelper.IsBroker(workplaceContext.User.EMail)) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "action", "Index" }, { "controller", "BrokerHome" }, { "Area", "Broker" } }); return; } // if } // if var isUnderwriter = workplaceContext.UserRoles.Any( x => x.ToLower() == "crm" || x.ToLower() == "manager" || x.ToLower() == "underwriter" ); if (isUnderwriter) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "action", "Index" }, { "controller", "Customers" }, { "Area", "Underwriter" } }); return; } // if var customer = workplaceContext.Customer; if (customer == null) { return; } var routeDictionary = new RouteValueDictionary { { "action", "Index" }, { "Area", "Customer" } }; if (customer.WizardStep.TheLastOne) { if (filterContext.RouteData.Values["controller"].ToString() == "Profile") { return; } routeDictionary.Add("controller", "Profile"); filterContext.Result = new RedirectToRouteResult(routeDictionary); } else { if (filterContext.RouteData.Values["controller"].ToString() == "Wizard") { return; } routeDictionary.Add("controller", "Wizard"); filterContext.Result = new RedirectToRouteResult(routeDictionary); } // if } // OnActionExecuting