/// <summary> /// Call for page with associated FirmaPage /// </summary> protected FirmaViewData(Person currentPerson, Models.FirmaPage firmaPage) { FirmaPage = firmaPage; CurrentPerson = currentPerson; FirmaHomeUrl = SitkaRoute <HomeController> .BuildUrlFromExpression(c => c.Index()); LogInUrl = FirmaHelpers.GenerateLogInUrlWithReturnUrl(); LogOutUrl = FirmaHelpers.GenerateLogOutUrlWithReturnUrl(); RequestSupportUrl = SitkaRoute <HelpController> .BuildUrlFromExpression(c => c.Support()); MakeFirmaMenu(currentPerson); FullProjectListUrl = SitkaRoute <ProjectController> .BuildUrlFromExpression(c => c.Index()); ProjectSearchUrl = SitkaRoute <ProjectController> .BuildUrlFromExpression(c => c.Search(UrlTemplate.Parameter1String)); ProjectFindUrl = SitkaRoute <ProjectController> .BuildUrlFromExpression(c => c.Find(string.Empty)); var currentPersonCanManage = new FirmaPageManageFeature().HasPermission(currentPerson, firmaPage).HasPermission; ViewPageContentViewData = firmaPage != null ? new ViewPageContentViewData(firmaPage, currentPersonCanManage) : null; CustomFooterViewData = new ViewPageContentViewData(Models.FirmaPage.GetFirmaPageByPageType(FirmaPageType.CustomFooter), currentPersonCanManage); TenantName = MultiTenantHelpers.GetTenantName(); TenantDisplayName = MultiTenantHelpers.GetTenantDisplayName(); TenantBannerLogoUrl = MultiTenantHelpers.GetTenantBannerLogoUrl(); }
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext) { var redirectToLogin = new RedirectResult(FirmaHelpers.GenerateLogInUrlWithReturnUrl()); if (!filterContext.HttpContext.User.Identity.IsAuthenticated) { filterContext.Result = redirectToLogin; return; } throw new SitkaRecordNotAuthorizedException($"You are not authorized for feature \"{FeatureName}\". Log out and log in as a different user or request additional permissions."); }