protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext) { var redirectToLogin = new RedirectResult(FirmaHelpers.GenerateLogInUrl()); 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."); }
/// <summary> /// Call for page with associated FirmaPage /// </summary> protected FirmaViewData(FirmaSession currentFirmaSession, ProjectFirmaModels.Models.FirmaPage firmaPage) { FirmaPage = firmaPage; //CurrentPerson = currentPerson; CurrentFirmaSession = currentFirmaSession; FirmaHomeUrl = SitkaRoute <HomeController> .BuildUrlFromExpression(c => c.Index()); LogInUrl = FirmaHelpers.GenerateLogInUrl(); LogOutUrl = FirmaHelpers.GenerateLogOutUrlWithReturnUrl(); CurrentUrl = HttpContext.Current.Request.Url; ForgotPasswordUrl = FirmaHelpers.GenerateForgotPasswordUrlWithReturnUrl(CurrentUrl.AbsoluteUri); RegisterAccountUrl = FirmaHelpers.GenerateCreateAccountWithReturnUrl(CurrentUrl.AbsoluteUri); QaUrl = MultiTenantHelpers.GetRelativeUrlForEnvironment(CurrentUrl, FirmaEnvironmentType.Qa); LocalUrl = MultiTenantHelpers.GetRelativeUrlForEnvironment(CurrentUrl, FirmaEnvironmentType.Local); ProdUrl = MultiTenantHelpers.GetRelativeUrlForEnvironment(CurrentUrl, FirmaEnvironmentType.Prod); TenantSimples = MultiTenantHelpers.GetAllTenantSimples().Where(ts => ts.ShowTenantInSwitcherDropdown).ToList(); RequestSupportUrl = SitkaRoute <HelpController> .BuildUrlFromExpression(c => c.Support()); MakeFirmaMenu(currentFirmaSession); 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(currentFirmaSession, firmaPage).HasPermission; ViewPageContentViewData = firmaPage != null ? new ViewPageContentViewData(firmaPage, currentPersonCanManage) : null; CustomFooterViewData = new CustomFooterViewData(FirmaPageTypeEnum.CustomFooter.GetFirmaPage(), currentPersonCanManage, this.CurrentFirmaSession); TenantName = MultiTenantHelpers.GetTenantName(); TenantShortDisplayName = MultiTenantHelpers.GetTenantShortDisplayName(); TenantBannerLogoUrl = MultiTenantHelpers.GetTenantBannerLogoUrl(); TenantToolDisplayName = MultiTenantHelpers.GetToolDisplayName(); ShowTenantDropdown = // Tenant dropdown can be globally disabled if necessary. (Reclamation needs this, and so might other hard-ish forks.) FirmaWebConfiguration.TenantDropdownEnabled && (FirmaWebConfiguration.FirmaEnvironment.FirmaEnvironmentType == FirmaEnvironmentType.Local || CurrentFirmaSession.IsSitkaAdministrator()); ShowEnvironmentLabel = FirmaWebConfiguration.FirmaEnvironment.FirmaEnvironmentType != FirmaEnvironmentType.Prod; ShowEnvironmentDropdown = FirmaWebConfiguration.FirmaEnvironment.FirmaEnvironmentType == FirmaEnvironmentType.Local || CurrentFirmaSession.IsSitkaAdministrator(); FirmaIncludesViewData = new FirmaIncludesViewData(); }