/// <summary> /// In-order for this to work with /// </summary> /// <param name="e"></param> protected override void OnInit(EventArgs e) { base.OnInit(e); var detailsView = this.Controls.OfType <RadListView>().FirstOrDefault(); if (detailsView != null) { detailsView.ItemDataBound += metaData_ItemDataBound; } else { DynamicDetailContainer dynamicContainer = Controls.OfType <DynamicDetailContainer>().FirstOrDefault(); if (dynamicContainer != null) { var dynamicContents = ((DynamicContent[])(dynamicContainer.DataSource)); if (dynamicContents.Length > 0) { DynamicContent dynamicArticle = dynamicContents[0]; if (dynamicArticle != null) { AddMetaDataTagsFromArticle(dynamicArticle); } } } } }
private void ValidatePermission(DynamicDetailContainer container) { DynamicContent[] detailItems = (DynamicContent[])container.DataSource; DynamicContent item = detailItems[0]; var identity = ClaimsManager.GetCurrentIdentity(); var url = Request.Url.OriginalString; var loginUrl = string.Format("~/Mxg/AuthService/SignInByHelix?ReturnUrl={0}", url.UrlDecode()); try { /*var manager = DynamicModuleManager.GetManager(); * Type contentType = TypeResolutionService * .ResolveType("Telerik.Sitefinity.DynamicTypes.Model.ResourcesProtected.ProtectedResource");*/ if (item != null) { //var det = item?.Issec.DataItem as DynamicContent; //var pressitem = manager.GetDataItem(contentType, new Guid(item.GetValue("Id").ToString())); //bool isSecgrand = pressitem.IsSecurityActionTypeGranted(SecurityActionTypes.View); bool isSecgrand = item.IsSecurityActionTypeGranted(SecurityActionTypes.View); log.InfoFormat("title is {0}-:{1}, permission:{2}, userid:{3}, isNullGuid:{4}", item.GetValue("Title"), item.GetValue("Id"), isSecgrand, identity.UserId, identity.UserId.IsNullOrEmptyGuid() ); if (isSecgrand == false) { Response.Redirect(identity.UserId.IsNullOrEmptyGuid() ? loginUrl : "~/account/not-authorized"); } } // not login & not granded } catch (Exception ex) { log.InfoFormat("exception from get dynamic:{0}- inner:{1}", ex.Message, ex.InnerException?.Message); //Response.Redirect("~/account/not-authorized"); Response.Redirect(identity.UserId.IsNullOrEmptyGuid() ? loginUrl : "~/account/not-authorized"); } }