/// <summary> /// This is basically the same as the logic in CBasePage.UserCanEditModule(). /// </summary> /// <param name="loginName"></param> /// <param name="postId">This is the same as itemid in Cynthia parlance.</param> /// <returns></returns> public bool CanUserEditPost(string loginName, int postId) { SiteUser user = new SiteUser(_siteSettings, loginName); if (user.IsInRoles("Admins;Content Administrators")) { return(true); } Blog blog = new Blog(postId); Module module = new Module(blog.ModuleId); if (module.EditUserId.Equals(user.UserId)) { return(true); } if (user.IsInRoles(module.AuthorizedEditRoles)) { return(true); } int pageId = GetPageIdForModule(blog.ModuleId); if (pageId > -1) { PageSettings blogPage = new PageSettings(_siteSettings.SiteId, pageId); if (user.IsInRoles(blogPage.EditRoles)) { return(true); } } return(false); }
private void ShowAnonymousProperties(SiteUser siteUser) { bool wouldSeeMoreIfAuthenticated = false; CProfileConfiguration profileConfig = CProfileConfiguration.GetConfig(); if (profileConfig != null) { foreach (CProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions) { if ( (propertyDefinition.VisibleToAnonymous) && (propertyDefinition.OnlyVisibleForRoles.Length == 0) && ( (propertyDefinition.OnlyAvailableForRoles.Length == 0) || (siteUser.IsInRoles(propertyDefinition.OnlyAvailableForRoles)) ) ) { object propValue = siteUser.GetProperty(propertyDefinition.Name, propertyDefinition.SerializeAs, propertyDefinition.LazyLoad); if (propValue != null) { CProfilePropertyDefinition.SetupReadOnlyPropertyControl( pnlProfileProperties, propertyDefinition, propValue.ToString(), timeOffset); } else { CProfilePropertyDefinition.SetupReadOnlyPropertyControl( pnlProfileProperties, propertyDefinition, propertyDefinition.DefaultValue, timeOffset); } } else { if ( (propertyDefinition.VisibleToAuthenticated) && (propertyDefinition.OnlyVisibleForRoles.Length == 0) && ( (propertyDefinition.OnlyAvailableForRoles.Length == 0) || (siteUser.IsInRoles(propertyDefinition.OnlyAvailableForRoles)) ) ) { wouldSeeMoreIfAuthenticated = true; } } } } if (wouldSeeMoreIfAuthenticated) { lblMessage.Text = ProfileResource.WouldSeeMoreIfAuthenticatedMessage; } }
private void ShowAuthenticatedProperties(SiteUser siteUser) { mojoProfileConfiguration profileConfig = mojoProfileConfiguration.GetConfig(); if (profileConfig != null) { foreach (mojoProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions) { #if !MONO // we are using the new TimeZoneInfo list but it doesn't work under Mono // this makes us skip the TimeOffsetHours setting from mojoProfile.config which is not used under windows if (propertyDefinition.Name == mojoProfilePropertyDefinition.TimeOffsetHoursKey) { continue; } #endif // we allow this to be configured as a profile property so it can be required for registration // but we don't need to load it here because we have a dedicated control for the property already if (propertyDefinition.Name == mojoProfilePropertyDefinition.TimeZoneIdKey) { continue; } if ( (propertyDefinition.VisibleToAuthenticated) && ( (propertyDefinition.OnlyAvailableForRoles.Length == 0) || (siteUser.IsInRoles(propertyDefinition.OnlyAvailableForRoles)) ) && ( (propertyDefinition.OnlyVisibleForRoles.Length == 0) || (WebUser.IsInRoles(propertyDefinition.OnlyVisibleForRoles)) ) ) { object propValue = siteUser.GetProperty(propertyDefinition.Name, propertyDefinition.SerializeAs, propertyDefinition.LazyLoad); if (propValue != null) { mojoProfilePropertyDefinition.SetupReadOnlyPropertyControl( pnlProfileProperties, propertyDefinition, propValue.ToString(), timeOffset, timeZone); } else { mojoProfilePropertyDefinition.SetupReadOnlyPropertyControl( pnlProfileProperties, propertyDefinition, propertyDefinition.DefaultValue, timeOffset, timeZone); } } } } }
protected bool CheckRoles(string roles) { if (roles.Contains("All Users")) { return(true); } if (siteUser != null) { if (siteUser.IsInRoles("Admins")) { return(true); } if (siteUser.IsInRoles(roles)) { return(true); } } return(false); }
public bool CanUserPostToBlog(string loginName, BlogInfo b) { SiteUser user = new SiteUser(_siteSettings, loginName); if (user.IsInRoles("Admins;Content Administrators")) { return(true); } if (user.IsInRoles(b.editRoles)) { return(true); } if (user.IsInRoles(b.moduleEditRoles)) { return(true); } return(false); }
protected void Page_Load(object sender, EventArgs e) { LoadSettings(); if ( ( ((WebUser.IsInRoles(CurrentSite.RolesThatCanManageUsers)) || (WebUser.IsInRoles(CurrentSite.RolesThatCanCreateUsers))) && !isAdmin) ) { // only admins can edit admins if (siteUser.IsInRoles("Admins")) { SiteUtils.RedirectToEditAccessDeniedPage(); return; } // HideAdminControls(); } else { if (!isAdmin) { if (!Request.IsAuthenticated) { SiteUtils.RedirectToLoginPage(this); return; } SiteUtils.RedirectToEditAccessDeniedPage(); return; } } PopulateLabels(); if (siteUser != null) { if (!IsPostBack) { BindRoles(); } } }
private void ShowAuthenticatedProperties(SiteUser siteUser) { CProfileConfiguration profileConfig = CProfileConfiguration.GetConfig(); if (profileConfig != null) { foreach (CProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions) { if ( (propertyDefinition.VisibleToAuthenticated) && ( (propertyDefinition.OnlyAvailableForRoles.Length == 0) || (siteUser.IsInRoles(propertyDefinition.OnlyAvailableForRoles)) ) && ( (propertyDefinition.OnlyVisibleForRoles.Length == 0) || (WebUser.IsInRoles(propertyDefinition.OnlyVisibleForRoles)) ) ) { object propValue = siteUser.GetProperty(propertyDefinition.Name, propertyDefinition.SerializeAs, propertyDefinition.LazyLoad); if (propValue != null) { CProfilePropertyDefinition.SetupReadOnlyPropertyControl( pnlProfileProperties, propertyDefinition, propValue.ToString(), timeOffset); } else { CProfilePropertyDefinition.SetupReadOnlyPropertyControl( pnlProfileProperties, propertyDefinition, propertyDefinition.DefaultValue, timeOffset); } } } } }
public MojoPortalUser() { try { if (HttpContext.Current.User.Identity.IsAuthenticated) { //UserInfo info = UserController.GetUserByName(((PortalSettings) HttpContext.Current.Items["PortalSettings"]).get_PortalId(), HttpContext.Current.User.Identity.Name, false); siteUser = SiteUtils.GetCurrentSiteUser(); this.m_userID = siteUser.UserId; this.m_userName = siteUser.LoginName; this.m_email = siteUser.Email; this.m_firstName = siteUser.Name; this.m_lastName = ""; this.m_location = siteUser.Country; this.m_isSuperAdmin = siteUser.IsInRoles("Administrators"); this.m_isAuthenticated = true; } } catch (Exception exception) { throw new Exception("Failed to find user info from mojoPortal.", exception); } }
private bool LoadAndCheckParams() { pageID = WebUtils.ParseInt32FromQueryString("pageid", -1); moduleID = WebUtils.ParseInt32FromQueryString("mid", -1); fileID = WebUtils.ParseInt32FromQueryString("fileid", -1); if (pageID == -1 || moduleID == -1 || fileID == -1) { return(false); } sharedFile = new SharedFile(moduleID, fileID); if (sharedFile.ModuleId != moduleID) { return(false); } bool canView = false; if (sharedFile.ViewRoles.Contains("All Users")) { canView = true; } SiteUser siteUser = SiteUtils.GetCurrentSiteUser(); if (siteUser != null) { if (siteUser.IsInRoles("Admins")) { canView = true; } if (siteUser.IsInRoles(sharedFile.ViewRoles)) { canView = true; } } if (canView) { FileSystemProvider p = FileSystemManager.Providers[WebConfigSettings.FileSystemProvider]; if (p == null) { log.Error($"Could not load file system provider {WebConfigSettings.FileSystemProvider}"); return(false); } fileSystem = p.GetFileSystem(); if (fileSystem == null) { log.Error($"Could not load file system from provider {WebConfigSettings.FileSystemProvider} "); return(false); } return(true); } return(false); }
private void PopulateProfileControls() { if (siteUser == null) { return; } gbProfileConfiguration profileConfig = gbProfileConfiguration.GetConfig(); if (profileConfig != null) { foreach (gbProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions) { #if !MONO if (propertyDefinition.Name == gbProfilePropertyDefinition.TimeOffsetHoursKey) { continue; } #endif if (propertyDefinition.Name == gbProfilePropertyDefinition.TimeZoneIdKey) { continue; } if ( (propertyDefinition.VisibleToUser) && ( (propertyDefinition.OnlyAvailableForRoles.Length == 0) || (siteUser.IsInRoles(propertyDefinition.OnlyAvailableForRoles)) ) ) { object propValue = siteUser.GetProperty(propertyDefinition.Name, propertyDefinition.SerializeAs, propertyDefinition.LazyLoad); if (propValue != null) { if (propertyDefinition.EditableByUser) { gbProfilePropertyDefinition.SetupPropertyControl( this, pnlProfileProperties, propertyDefinition, propValue.ToString(), timeOffset, timeZone, SiteRoot); } else { gbProfilePropertyDefinition.SetupReadOnlyPropertyControl( pnlProfileProperties, propertyDefinition, propValue.ToString(), timeOffset, timeZone); } } else { if (propertyDefinition.EditableByUser) { gbProfilePropertyDefinition.SetupPropertyControl( this, pnlProfileProperties, propertyDefinition, propertyDefinition.DefaultValue, timeOffset, timeZone, SiteRoot); } else { gbProfilePropertyDefinition.SetupReadOnlyPropertyControl( pnlProfileProperties, propertyDefinition, propertyDefinition.DefaultValue, timeOffset, timeZone); } } } } } }
private void Page_Load(object sender, EventArgs e) { if (SiteUtils.SslIsAvailable()) { SiteUtils.ForceSsl(); } SecurityHelper.DisableBrowserCache(); if (userID == -1) { if (!WebUser.IsInRoles(siteSettings.RolesThatCanManageUsers)) { SiteUtils.RedirectToEditAccessDeniedPage(); return; } } else { if (WebUser.IsInRoles(siteSettings.RolesThatCanManageUsers) && !isAdmin) { // only admins can edit admins if (siteUser.IsInRoles("Admins")) { SiteUtils.RedirectToEditAccessDeniedPage(); return; } HideNonAdminControls(); } else { if (!isAdmin) { SiteUtils.RedirectToEditAccessDeniedPage(); return; } } } SetupAvatarScript(); this.divUserGuid.Visible = false; divProfileApproved.Visible = false; divApprovedForGroups.Visible = false; divOpenID.Visible = ((WebConfigSettings.EnableOpenIdAuthentication && siteSettings.AllowOpenIdAuth) || siteSettings.RpxNowApiKey.Length > 0); divWindowsLiveID.Visible = WebConfigSettings.EnableWindowsLiveAuthentication && siteSettings.AllowWindowsLiveAuth; PopulateProfileControls(); //if (!allowGravatars) //{ // if (disableOldAvatars) // { // divAvatarUrl.Visible = false; // } // else // { // AvatarPath = ImageSiteRoot + "/Data/Sites/" + siteSettings.SiteId.ToString() + "/avatars/"; // } //} PopulateLabels(); //SetupAvatarScript(); if (!IsPostBack) { PopulateControls(); } }