Пример #1
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);
                        }
                    }
                }
            }
        }
        private bool IsValidForUserCreation(OpenIdEventArgs e, ClaimsResponse claim)
        {
            bool result = true;

            if (claim == null)
            {
                return(false);
            }

            if (String.IsNullOrEmpty(claim.Email))
            {
                return(false);
            }
            if (String.IsNullOrEmpty(claim.FullName))
            {
                return(false);
            }

            if (!Email.IsValidEmailAddressSyntax(claim.Email))
            {
                return(false);
            }

            mojoProfileConfiguration profileConfig = mojoProfileConfiguration.GetConfig();

            if (profileConfig.HasRequiredCustomProperties())
            {
                result = false;
            }

            return(result);
        }
        private bool IsValidForUserCreation(OpenIdEventArgs e, ClaimsResponse claim)
        {
            if (e == null)
            {
                return(false);
            }
            if (claim == null)
            {
                return(false);
            }
            if (e.ClaimedIdentifier == null)
            {
                return(false);
            }

            if (String.IsNullOrEmpty(claim.Email))
            {
                return(false);
            }
            if (String.IsNullOrEmpty(claim.FullName))
            {
                return(false);
            }

            if (!Email.IsValidEmailAddressSyntax(claim.Email))
            {
                return(false);
            }

            // if custom profile fields are required
            // must pass them on to registration page
            mojoProfileConfiguration profileConfig = mojoProfileConfiguration.GetConfig();

            if (profileConfig != null)
            {
                if (profileConfig.HasRequiredCustomProperties())
                {
                    return(false);
                }
            }

            return(true);
        }
        private void LoadSettings()
        {
            timeOffset = SiteUtils.GetUserTimeOffset();
            timeZone   = SiteUtils.GetUserTimeZone();

            if (SiteUtils.SslIsAvailable())
            {
                protocol = "https://";
            }

            mojoProfileConfiguration profileConfig
                = mojoProfileConfiguration.GetConfig();

            foreach (mojoProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions)
            {
                if ((propertyDefinition.RequiredForRegistration) || (propertyDefinition.ShowOnRegistration))
                {
                    requiredProfileProperties.Add(propertyDefinition);
                }
            }

            winliveCookieName = "winliveid" + siteSettings.SiteId.ToString(CultureInfo.InvariantCulture);

            windowsLive = WindowsLiveHelper.GetWindowsLiveLogin();
            if (windowsLive == null)
            {
                return;
            }

            windowsLiveAppId = windowsLive.AppId;

            string winLiveToken = CookieHelper.GetCookieValue(winliveCookieName);

            if (winLiveToken.Length > 0)
            {
                liveUser = windowsLive.ProcessToken(winLiveToken);
            }


            AddClassToBody("registerwinlivepage");
        }
Пример #5
0
        private void PopulateRequiredProfileControls()
        {
            //foreach (mojoProfilePropertyDefinition propertyDefinition in requiredProfileProperties)
            //{
            //    mojoProfilePropertyDefinition.SetupPropertyControl(
            //        this,
            //        pnlRequiredProfileProperties,
            //        propertyDefinition,
            //        timeOffset,
            //        timeZone,
            //        SiteRoot);
            //}

            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
                    if ((propertyDefinition.RequiredForRegistration) || (propertyDefinition.ShowOnRegistration))
                    {
                        mojoProfilePropertyDefinition.SetupPropertyControl(
                            this,
                            pnlRequiredProfileProperties,
                            propertyDefinition,
                            timeOffset,
                            timeZone,
                            SiteRoot);
                    }
                }
            }
        }
        private void LoadSettings()
        {
            timeOffset = SiteUtils.GetUserTimeOffset();
            timeZone   = SiteUtils.GetUserTimeZone();

            mojoProfileConfiguration profileConfig
                = mojoProfileConfiguration.GetConfig();

            foreach (mojoProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions)
            {
                if ((propertyDefinition.RequiredForRegistration) || (propertyDefinition.ShowOnRegistration))
                {
                    requiredProfileProperties.Add(propertyDefinition);
                }
            }

            openidCookieName         = "openid" + siteSettings.SiteId.ToString(CultureInfo.InvariantCulture);
            openIdEmailCookieName    = "openidemail" + siteSettings.SiteId.ToString(CultureInfo.InvariantCulture);
            openIdFullNameCookieName = "openidname" + siteSettings.SiteId.ToString(CultureInfo.InvariantCulture);

            AddClassToBody("registeropenidpage");
        }
Пример #7
0
        private bool IsValidForUserCreation(OpenIdRpxAuthInfo authInfo)
        {
            bool result = true;

            if (authInfo == null)
            {
                return(false);
            }

            if (String.IsNullOrEmpty(authInfo.Email))
            {
                return(false);
            }
            if (termsOfUse.Length > 0)
            {
                return(false);
            }
            if ((displaySettings.ShowNewsLetters) && (siteAvailableSubscriptions.Count > 0))
            {
                return(false);
            }


            if (!Email.IsValidEmailAddressSyntax(authInfo.Email))
            {
                return(false);
            }

            mojoProfileConfiguration profileConfig = mojoProfileConfiguration.GetConfig();

            if (profileConfig.HasRequiredCustomProperties())
            {
                result = false;
            }

            return(result);
        }
Пример #8
0
        private void UpdateUser()
        {
            userEmail = siteUser.Email;

            if (
                (siteUser.Email != txtEmail.Text) &&
                (SiteUser.EmailExistsInDB(siteSettings.SiteId, siteUser.UserId, txtEmail.Text))
                )
            {
                lblErrorMessage.Text = Resource.DuplicateEmailMessage;
                return;
            }

            if ((siteSettings.AllowUserEditorPreference) && (divEditorPreference.Visible))
            {
                siteUser.EditorPreference = ddEditorProviders.SelectedValue;
            }

            if (siteSettings.AllowUserFullNameChange)
            {
                siteUser.Name = txtName.Text;
            }
            siteUser.Email = txtEmail.Text;

            if (WebConfigSettings.LogIpAddressForEmailChanges)
            {
                if ((siteUser.UserId != -1) && (userEmail != siteUser.Email))
                {
                    log.Info("email for user changed from " + userEmail + " to " + siteUser.Email + " from ip address " + SiteUtils.GetIP4Address());
                }
            }

            if (pnlSecurityQuestion.Visible)
            {
                siteUser.PasswordQuestion = this.txtPasswordQuestion.Text;
                siteUser.PasswordAnswer   = this.txtPasswordAnswer.Text;
            }
            else
            {
                //in case it is ever changed later to require password question and answer after making it not required
                // we need to ensure there is some question and answer.
                if (siteUser.PasswordQuestion.Length == 0)
                {
                    siteUser.PasswordQuestion = Resource.ManageUsersDefaultSecurityQuestion;
                    siteUser.PasswordAnswer   = Resource.ManageUsersDefaultSecurityAnswer;
                }
            }


            if (siteUser.LiveMessengerId.Length > 0)
            {
                siteUser.EnableLiveMessengerOnProfile = chkEnableLiveMessengerOnProfile.Checked;
            }
            else
            {
                siteUser.EnableLiveMessengerOnProfile = false;
            }

            if (allowUserSkin)
            {
                siteUser.Skin = SkinSetting.GetValue();
                //if (ddSkins.SelectedValue != "printerfriendly")
                //{
                //    siteUser.Skin = ddSkins.SelectedValue;
                //}
            }

#if !MONO
            ISettingControl setting = timeZoneSetting as ISettingControl;
            if (setting != null)
            {
                siteUser.TimeZoneId = setting.GetValue();
            }
#endif

            //if ((!disableOldAvatars)&&(!WebConfigSettings.OnlyAdminsCanEditCheesyAvatars))
            //{ siteUser.AvatarUrl = ddAvatars.SelectedValue; }
            siteUser.PasswordFormat = siteSettings.PasswordFormat;

            if (siteUser.Save())
            {
                mojoProfileConfiguration profileConfig = mojoProfileConfiguration.GetConfig();

                foreach (mojoProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions)
                {
                    if (
                        (propertyDefinition.EditableByUser) &&
                        (
                            (propertyDefinition.OnlyAvailableForRoles.Length == 0) ||
                            (WebUser.IsInRoles(propertyDefinition.OnlyAvailableForRoles))
                        )
                        )
                    {
                        mojoProfilePropertyDefinition.SaveProperty(
                            siteUser,
                            pnlProfileProperties,
                            propertyDefinition,
                            timeOffset,
                            timeZone);
                    }
                }

                siteUser.UpdateLastActivityTime();
                if ((userEmail != siteUser.Email) && (siteSettings.UseEmailForLogin) && (!siteSettings.UseLdapAuth))
                {
                    FormsAuthentication.SetAuthCookie(siteUser.Email, false);
                }

                ProfileUpdatedEventArgs u = new ProfileUpdatedEventArgs(siteUser, false);
                OnUserUpdated(u);

                SiteUtils.SetSkinCookie(siteUser);
                WebUtils.SetupRedirect(this, Request.RawUrl);
                return;
            }
        }
        private void CreateUser(
            string openId,
            string email,
            string loginName,
            string name)
        {
            SiteUser newUser = new SiteUser(siteSettings);

            newUser.Email = email;

            if (loginName.Length > 50)
            {
                loginName = loginName.Substring(0, 50);
            }

            int i = 1;

            while (SiteUser.LoginExistsInDB(
                       siteSettings.SiteId, loginName))
            {
                loginName += i.ToString();
                if (loginName.Length > 50)
                {
                    loginName = loginName.Remove(40, 1);
                }
                i++;
            }
            if ((name == null) || (name.Length == 0))
            {
                name = loginName;
            }
            newUser.LoginName = loginName;
            newUser.Name      = name;
            //newUser.Password = SiteUser.CreateRandomPassword(7);
            mojoMembershipProvider mojoMembership = (mojoMembershipProvider)Membership.Provider;

            newUser.Password         = mojoMembership.EncodePassword(siteSettings, newUser, SiteUser.CreateRandomPassword(7, WebConfigSettings.PasswordGeneratorChars));
            newUser.PasswordQuestion = Resource.ManageUsersDefaultSecurityQuestion;
            newUser.PasswordAnswer   = Resource.ManageUsersDefaultSecurityAnswer;
            newUser.OpenIdUri        = openId;
            newUser.Save();
            if (siteSettings.UseSecureRegistration)
            {
                newUser.SetRegistrationConfirmationGuid(Guid.NewGuid());
            }

            mojoProfileConfiguration profileConfig
                = mojoProfileConfiguration.GetConfig();

            // set default values first
            foreach (mojoProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions)
            {
                mojoProfilePropertyDefinition.SavePropertyDefault(
                    newUser, propertyDefinition);
            }

            foreach (mojoProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions)
            {
                if ((propertyDefinition.RequiredForRegistration) || (propertyDefinition.ShowOnRegistration))
                {
                    mojoProfilePropertyDefinition.SaveProperty(
                        newUser,
                        pnlRequiredProfileProperties,
                        propertyDefinition,
                        timeOffset,
                        timeZone);
                }
            }

            // track user ip address
            UserLocation userLocation = new UserLocation(newUser.UserGuid, SiteUtils.GetIP4Address());

            userLocation.SiteGuid = siteSettings.SiteGuid;
            userLocation.Hostname = Page.Request.UserHostName;
            userLocation.Save();

            UserRegisteredEventArgs u = new UserRegisteredEventArgs(newUser);

            OnUserRegistered(u);

            CacheHelper.ClearMembershipStatisticsCache();

            NewsletterHelper.ClaimExistingSubscriptions(newUser);

            DoUserLogin(newUser);
        }
Пример #10
0
        private SiteUser CreateUser(
            string openId,
            string email,
            string loginName,
            string name,
            bool emailIsVerified)
        {
            SiteUser newUser = new SiteUser(siteSettings);

            newUser.Email = email;

            if (loginName.Length > 50)
            {
                loginName = loginName.Substring(0, 50);
            }

            int i = 1;

            while (SiteUser.LoginExistsInDB(
                       siteSettings.SiteId, loginName))
            {
                loginName += i.ToString();
                if (loginName.Length > 50)
                {
                    loginName = loginName.Remove(40, 1);
                }
                i++;
            }
            if ((name == null) || (name.Length == 0))
            {
                name = loginName;
            }
            newUser.LoginName = loginName;
            newUser.Name      = name;
            //newUser.Password = SiteUser.CreateRandomPassword(7);
            mojoMembershipProvider mojoMembership = (mojoMembershipProvider)Membership.Provider;

            newUser.Password         = mojoMembership.EncodePassword(siteSettings, newUser, SiteUser.CreateRandomPassword(7, WebConfigSettings.PasswordGeneratorChars));
            newUser.PasswordQuestion = Resource.ManageUsersDefaultSecurityQuestion;
            newUser.PasswordAnswer   = Resource.ManageUsersDefaultSecurityAnswer;
            newUser.OpenIdUri        = openId;
            newUser.Save();

            //test
            //emailIsVerified = false;

            if (siteSettings.UseSecureRegistration)
            {
                if (!emailIsVerified)
                {
                    newUser.SetRegistrationConfirmationGuid(Guid.NewGuid());
                }
            }



            mojoProfileConfiguration profileConfig
                = mojoProfileConfiguration.GetConfig();

            // set default values first
            foreach (mojoProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions)
            {
                // 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;
                }
                mojoProfilePropertyDefinition.SavePropertyDefault(
                    newUser, propertyDefinition);
            }

            foreach (mojoProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions)
            {
                // 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;
                }
                if ((propertyDefinition.RequiredForRegistration) || (propertyDefinition.ShowOnRegistration))
                {
                    mojoProfilePropertyDefinition.SaveProperty(
                        newUser,
                        pnlRequiredProfileProperties,
                        propertyDefinition,
                        timeOffset,
                        timeZone);
                }
            }

            // track user ip address
            UserLocation userLocation = new UserLocation(newUser.UserGuid, SiteUtils.GetIP4Address());

            userLocation.SiteGuid = siteSettings.SiteGuid;
            userLocation.Hostname = Page.Request.UserHostName;
            userLocation.Save();

            UserRegisteredEventArgs u = new UserRegisteredEventArgs(newUser);

            OnUserRegistered(u);

            CacheHelper.ClearMembershipStatisticsCache();

            // we'll map them next time they login
            //OpenIdRpxHelper rpxHelper = new OpenIdRpxHelper(rpxApiKey, rpxBaseUrl);
            //rpxHelper.Map(openId, newUser.UserGuid.ToString());

            DoSubscribe(newUser);

            NewsletterHelper.ClaimExistingSubscriptions(newUser);

            return(newUser);
        }
Пример #11
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;
            }
        }
Пример #12
0
        private void LoadSettings()
        {
            timeOffset = SiteUtils.GetUserTimeOffset();
            timeZone   = SiteUtils.GetUserTimeZone();
            //lnkAllUsers.NavigateUrl = SiteRoot + "/MemberList.aspx";
            IsAdmin = WebUser.IsAdmin;

            ShowEmailInMemberList     = WebConfigSettings.ShowEmailInMemberList || displaySettings.ShowEmail;
            ShowUserIDInMemberList    = WebConfigSettings.ShowUserIDInMemberList || displaySettings.ShowUserId;
            ShowLoginNameInMemberList = WebConfigSettings.ShowLoginNameInMemberList || displaySettings.ShowLoginName;
            ShowJoinDate = displaySettings.ShowJoinDate;

            // this can't be used in related site mode because we can't assume forum posts were in this site.
            ShowForumPostColumn = WebConfigSettings.ShowForumPostsInMemberList && displaySettings.ShowForumPosts && !WebConfigSettings.UseRelatedSiteMode;

            allowView = WebUser.IsInRoles(siteSettings.RolesThatCanViewMemberList);

            if ((IsAdmin) || (WebUser.IsInRoles(siteSettings.RolesThatCanManageUsers)))
            {
                canManageUsers        = true;
                spnIPLookup.Visible   = true;
                btnFindLocked.Visible = true;
            }


            btnFindNotApproved.Visible = canManageUsers && siteSettings.RequireApprovalBeforeLogin;

            if (canManageUsers || WebUser.IsInRoles(siteSettings.RolesThatCanCreateUsers))
            {
                lnkNewUser.Visible     = true;
                lnkNewUser.Text        = Resource.MemberListAddUserLabel;
                lnkNewUser.NavigateUrl = SiteRoot + "/Admin/ManageUsers.aspx?userId=-1";
            }

            pageNumber = WebUtils.ParseInt32FromQueryString("pagenumber", 1);

            sortMode = WebUtils.ParseInt32FromQueryString("sd", sortMode);

            if ((sortMode == 0) && (displaySettings.ShowFirstAndLastName))
            {
                sortMode = 2; // lastname, firstname
            }

            if (Request.Params["letter"] != null)
            {
                userNameBeginsWith = Request.Params["letter"].Trim();
            }

            if (Request.Params["search"] != null)
            {
                searchText = Request.Params["search"].Trim();
            }

            showLocked     = WebUtils.ParseBoolFromQueryString("locked", showLocked);
            showUnApproved = WebUtils.ParseBoolFromQueryString("needapproval", showUnApproved);

            pageSize = WebConfigSettings.MemberListPageSize;

            mojoProfileConfiguration profileConfig = mojoProfileConfiguration.GetConfig();

            if (profileConfig != null)
            {
                if (profileConfig.Contains("WebSiteUrl"))
                {
                    mojoProfilePropertyDefinition webSiteUrlProperty = profileConfig.GetPropertyDefinition("WebSiteUrl");
                    if (
                        (webSiteUrlProperty.OnlyVisibleForRoles.Length == 0) ||
                        (WebUser.IsInRoles(webSiteUrlProperty.OnlyVisibleForRoles))
                        )
                    {
                        ShowWebSiteColumn = true;
                    }
                }
            }

            // displaySettings can be configured from theme.skin
            if (displaySettings.HideWebSiteColumn)
            {
                ShowWebSiteColumn = false;
            }

            if (displaySettings.TableCssClass.Length > 0)
            {
                tableClassMarkup = " class='" + displaySettings.TableCssClass + "'";
            }

            tableAttributes = displaySettings.TableAttributes;

            if (!ShowWebSiteColumn)
            {
                thWebLink.Visible = false;
            }
            if (!ShowJoinDate)
            {
                thJoinDate.Visible = false;
            }



            if (IsAdmin)
            {
                pnlAdminCrumbs.Visible = true;
            }

            if (!ShowForumPostColumn)
            {
                thForumPosts.Visible = false;
            }

            //this page has no content other than nav
            SiteUtils.AddNoIndexFollowMeta(Page);

            AddClassToBody("memberlist");

            if (displaySettings.TableCssClass == "jqtable")
            {
                ScriptConfig.IncludeJQTable = true;
            }
        }
        private void CreateUser(string windowsLiveId)
        {
            SiteUser newUser = new SiteUser(siteSettings);

            newUser.WindowsLiveId = windowsLiveId;
            newUser.Name          = SecurityHelper.RemoveMarkup(txtUserName.Text);
            newUser.LoginName     = newUser.Name;
            newUser.Email         = txtEmail.Text;
            mojoMembershipProvider mojoMembership = (mojoMembershipProvider)Membership.Provider;

            newUser.Password = mojoMembership.EncodePassword(siteSettings, newUser, SiteUser.CreateRandomPassword(7, WebConfigSettings.PasswordGeneratorChars));
            //newUser.Password = SiteUser.CreateRandomPassword(7);
            newUser.PasswordQuestion = Resource.ManageUsersDefaultSecurityQuestion;
            newUser.PasswordAnswer   = Resource.ManageUsersDefaultSecurityAnswer;
            newUser.Save();
            if (siteSettings.UseSecureRegistration)
            {
                newUser.SetRegistrationConfirmationGuid(Guid.NewGuid());
            }

            mojoProfileConfiguration profileConfig
                = mojoProfileConfiguration.GetConfig();

            // set default values first
            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
                mojoProfilePropertyDefinition.SavePropertyDefault(
                    newUser, propertyDefinition);
            }

            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
                if ((propertyDefinition.RequiredForRegistration) || (propertyDefinition.ShowOnRegistration))
                {
                    mojoProfilePropertyDefinition.SaveProperty(
                        newUser,
                        pnlRequiredProfileProperties,
                        propertyDefinition,
                        timeOffset,
                        timeZone);
                }
            }

            // track user ip address
            UserLocation userLocation = new UserLocation(newUser.UserGuid, SiteUtils.GetIP4Address());
            userLocation.SiteGuid = siteSettings.SiteGuid;
            userLocation.Hostname = Page.Request.UserHostName;
            userLocation.Save();

            UserRegisteredEventArgs u = new UserRegisteredEventArgs(newUser);
            OnUserRegistered(u);

            CacheHelper.ClearMembershipStatisticsCache();

            NewsletterHelper.ClaimExistingSubscriptions(newUser);

            DoUserLogin(newUser);
        }