Ejemplo n.º 1
0
        /// <summary>
        /// Loads the security configuration.
        /// </summary>
        /// <param name="wiki">The wiki.</param>
        private void LoadSecurityConfig(string currentWiki)
        {
            chkAllowUsersToRegister.Checked = Settings.UsersCanRegister(currentWiki);
            PopulateAccountActivationMode(Settings.GetAccountActivationMode(currentWiki));
            PopulateDefaultGroups(Settings.GetUsersGroup(currentWiki),
                                  Settings.GetAdministratorsGroup(currentWiki),
                                  Settings.GetAnonymousGroup(currentWiki));
            chkEnableCaptchaControl.Checked     = !Settings.GetDisableCaptchaControl(currentWiki);
            chkPreventConcurrentEditing.Checked = Settings.GetDisableConcurrentEditing(currentWiki);

            switch (Settings.GetModerationMode(currentWiki))
            {
            case ChangeModerationMode.None:
                rdoNoModeration.Checked = true;
                break;

            case ChangeModerationMode.RequirePageViewingPermissions:
                rdoRequirePageViewingPermissions.Checked = true;
                break;

            case ChangeModerationMode.RequirePageEditingPermissions:
                rdoRequirePageEditingPermissions.Checked = true;
                break;
            }

            txtExtensionsAllowed.Text = string.Join(", ", Settings.GetAllowedFileTypes(currentWiki));

            lstFileDownloadCountFilterMode.SelectedIndex = -1;
            switch (Settings.GetFileDownloadCountFilterMode(currentWiki))
            {
            case FileDownloadCountFilterMode.CountAll:
                lstFileDownloadCountFilterMode.SelectedIndex = 0;
                txtFileDownloadCountFilter.Enabled           = false;
                break;

            case FileDownloadCountFilterMode.CountSpecifiedExtensions:
                lstFileDownloadCountFilterMode.SelectedIndex = 1;
                txtFileDownloadCountFilter.Enabled           = true;
                txtFileDownloadCountFilter.Text = string.Join(", ", Settings.GetFileDownloadCountFilter(currentWiki));
                break;

            case FileDownloadCountFilterMode.ExcludeSpecifiedExtensions:
                txtFileDownloadCountFilter.Text              = string.Join(", ", Settings.GetFileDownloadCountFilter(currentWiki));
                txtFileDownloadCountFilter.Enabled           = true;
                lstFileDownloadCountFilterMode.SelectedIndex = 2;
                break;

            default:
                throw new NotSupportedException();
            }

            chkAllowScriptTags.Checked = Settings.GetScriptTagsAllowed(currentWiki);
            txtIpHostFilter.Text       = Settings.GetIpHostFilter(currentWiki);
        }
Ejemplo n.º 2
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            if (!Settings.UsersCanRegister(currentWiki))
            {
                return;
            }

            lblResult.Text     = "";
            lblResult.CssClass = "";

            Page.Validate();
            if (!Page.IsValid)
            {
                return;
            }

            // Ready to save the user
            Log.LogEntry("Account creation requested for " + txtUsername.Text, EntryType.General, Log.SystemUsername, currentWiki);
            Users.AddUser(currentWiki, txtUsername.Text, txtDisplayName.Text, txtPassword1.Text, txtEmail1.Text,
                          Settings.GetAccountActivationMode(currentWiki) == AccountActivationMode.Auto, null);

            UserInfo newUser = Users.FindUser(currentWiki, txtUsername.Text);

            // Set membership to default Users group
            Users.SetUserMembership(newUser, new string[] { Settings.GetUsersGroup(currentWiki) });

            if (Settings.GetAccountActivationMode(currentWiki) == AccountActivationMode.Email)
            {
                string body = Settings.GetProvider(currentWiki).GetMetaDataItem(MetaDataItem.AccountActivationMessage, null);
                body = body.Replace("##WIKITITLE##", Settings.GetWikiTitle(currentWiki)).Replace("##USERNAME##", newUser.Username).Replace("##EMAILADDRESS##", GlobalSettings.ContactEmail);
                body = body.Replace("##ACTIVATIONLINK##", Settings.GetMainUrl(currentWiki) + "Login.aspx?Activate=" + Tools.ComputeSecurityHash(newUser.Username, newUser.Email, newUser.DateTime) + "&Username="******"Account Activation - " + Settings.GetWikiTitle(currentWiki), body, false);
            }

            lblResult.CssClass  = "resultok";
            lblResult.Text      = "<br /><br />" + Properties.Messages.AccountCreated;
            btnRegister.Enabled = false;
            pnlRegister.Visible = false;
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            currentWiki = DetectWiki();

            if (SessionFacade.LoginKey != null)
            {
                UrlTools.Redirect("Profile.aspx");
                return;
            }

            // Test whether the default Users Provider is read-only
            IUsersStorageProviderV40 p = Collectors.CollectorsBox.UsersProviderCollector.GetProvider(GlobalSettings.DefaultUsersProvider, currentWiki);

            if (p.UserAccountsReadOnly)
            {
                Log.LogEntry("Default Users Provider (" + p.Information.Name + ") is read-only, aborting Account Creation", EntryType.Warning, Log.SystemUsername, currentWiki);
                UrlTools.Redirect(UrlTools.BuildUrl(currentWiki, "Error.aspx"));
            }

            PrintRegisterNotice();

            Page.Title = Properties.Messages.RegisterTitle + " - " + Settings.GetWikiTitle(currentWiki);

            if (!Settings.UsersCanRegister(currentWiki))
            {
                UrlTools.Redirect(UrlTools.BuildUrl(currentWiki, "AccessDenied.aspx"));
            }

            switch (Settings.GetAccountActivationMode(currentWiki))
            {
            case AccountActivationMode.Email:
                lblAccountActivationMode.Text = Properties.Messages.ActivationEmail;
                break;

            case AccountActivationMode.Administrator:
                lblAccountActivationMode.Text = Properties.Messages.ActivationAdmin;
                break;

            case AccountActivationMode.Auto:
                lblAccountActivationMode.Text = Properties.Messages.ActivationAuto;
                break;
            }

            if (Settings.GetDisableCaptchaControl(currentWiki))
            {
                lblCaptcha.Visible = false;
                captcha.Visible    = false;
            }

            if (!Page.IsPostBack)
            {
                rxvUserName.ValidationExpression    = GlobalSettings.UsernameRegex;
                rxvDisplayName.ValidationExpression = GlobalSettings.DisplayNameRegex;
                rxvEmail1.ValidationExpression      = GlobalSettings.EmailRegex;
                rxvPassword1.ValidationExpression   = GlobalSettings.PasswordRegex;
            }

            if (Page.IsPostBack)
            {
                // Preserve password value (a bit insecure but much more usable)
                txtPassword1.Attributes.Add("value", txtPassword1.Text);
                txtPassword2.Attributes.Add("value", txtPassword2.Text);
            }
        }