public async Task <IViewComponentResult> InvokeAsync(string pageId = "") { IList <SecurityClaimConfig> configurations = new List <SecurityClaimConfig>(); var userContext = _adminContextAccessor.GetContext().UserContext; var securityPoolId = _siteContext.SecurityPoolId; if (configurations == null) { configurations = new List <SecurityClaimConfig>(); } SecurityClaimConfig config = new SecurityClaimConfig { Title = "Private Audience", Description = "Manage who can view this page.", AllowRoles = true, AllowUsers = true, Claim = new Claim(PageClaimTypes.ViewPrivatePage, pageId), SecurityPoolId = securityPoolId, ResourceType = typeof(Models.Page).ToString() }; configurations.Add(config); var componentId = (string)ViewData["cid"]; return(await _securityUserRoleClaims.InvokeAsync(configurations, componentId)); }
public async Task <IViewComponentResult> InvokeAsync(string categoryId = "") { IList <SecurityClaimConfig> configurations = new List <SecurityClaimConfig>(); var userContext = _userContextAccessor.GetContext(); var siteContext = _siteContextAccessor.GetContext(); if (!string.IsNullOrEmpty(categoryId)) { var announcementCategory = _announcementManager.GetAnnouncementCategory(categoryId); if (announcementCategory.UserId != userContext.UserId) { throw new UnauthorizedAccessException(); } } if (configurations == null) { configurations = new List <SecurityClaimConfig>(); } SecurityClaimConfig config = new SecurityClaimConfig { Title = "Contribute / Post", AllowRoles = true, AllowUsers = true, AllowGroups = true, Claim = new Claim(AnnouncementClaimTypes.AnnouncementCategoryContribute, categoryId), SecurityPoolId = siteContext.SecurityPoolId, ResourceType = typeof(Models.AnnouncementCategory).ToString() }; configurations.Add(config); return(await _securityUserRoleClaims.InvokeAsync(configurations)); }
public async Task <IViewComponentResult> InvokeAsync(string eventGroupId = "") { IList <SecurityClaimConfig> configurations = new List <SecurityClaimConfig>(); var userContext = _userContextAccessor.GetContext(); var siteContext = _siteContextAccessor.GetContext(); if (!string.IsNullOrEmpty(eventGroupId)) { var eventGroup = _calendarqueryService.GetEventGroup(eventGroupId); if (eventGroup.UserId != userContext.UserId) { throw new UnauthorizedAccessException(); } } if (configurations == null) { configurations = new List <SecurityClaimConfig>(); } SecurityClaimConfig config = new SecurityClaimConfig { Title = "Access to Events", AllowRoles = true, AllowUsers = true, AllowGroups = true, Claim = new Claim(CalendarClaimTypes.CalendarEventGroupContribute, eventGroupId), SecurityPoolId = siteContext.SecurityPoolId, ResourceType = typeof(CalendarEventGroups).ToString() }; configurations.Add(config); return(await _securityUserRoleClaims.InvokeAsync(configurations)); }