Example #1
0
 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);
     }
 }
Example #2
0
        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);

                        }
                    }

                }
            }
        }
Example #3
0
        private void ShowAnonymousProperties(SiteUser siteUser)
        {
            bool wouldSeeMoreIfAuthenticated = false;

            mojoProfileConfiguration profileConfig = mojoProfileConfiguration.GetConfig();
            if (profileConfig != null)
            {
                foreach (mojoProfilePropertyDefinition 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)
                        {
                            mojoProfilePropertyDefinition.SetupReadOnlyPropertyControl(
                                pnlProfileProperties,
                                propertyDefinition,
                                propValue.ToString(),
                                timeOffset,
                                timeZone);
                        }
                        else
                        {
                            mojoProfilePropertyDefinition.SetupReadOnlyPropertyControl(
                                pnlProfileProperties,
                                propertyDefinition,
                                propertyDefinition.DefaultValue,
                                timeOffset,
                                timeZone);
                        }
                    }
                    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 SiteUser GetSiteUser(string loginName)
        {
            siteUser = new SiteUser(siteSettings, loginName);
            if (siteUser.UserId == -1) { return null; }

            if (siteUser.IsInRoles("Admins"))
            {
                isAdmin = true;
            }

            if (!isAdmin)
            {
                if (siteUser.IsInRoles("Content Administrators"))
                {
                    isContentAdmin = true;
                }
            }

            if ((!isAdmin) && (!isContentAdmin))
            {
                if (WebConfigSettings.UseRelatedSiteMode)
                {
                    isSiteEditor = siteUser.IsInRoles(siteSettings.SiteRootEditRoles);
                }
            }

            if (siteUser.TimeZoneId.Length > 0)
            {
                timeZone = SiteUtils.GetTimeZone(siteUser.TimeZoneId);
            }
            else
            {
                timeZone = SiteUtils.GetTimeZone(siteSettings.TimeZoneId);
            }

            return siteUser;
        }