예제 #1
0
        protected override void loadData()
        {
            ph.AddControlsReturnThis(new LegacyParagraph("You may report any problems, make suggestions, or ask for help here."));

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                PostBack.CreateFull(firstModificationMethod: modifyData, actionGetter: () => new PostBackAction(new ExternalResourceInfo(info.ReturnUrl)))
                .ToCollection(),
                () => {
                var list = FormItemList.CreateStack();
                list.AddFormItems(
                    new EmailAddress(AppTools.User.Email, AppTools.User.FriendlyName).ToMailAddress()
                    .ToString()
                    .ToComponents()
                    .ToFormItem(label: "From".ToComponents()),
                    "{0} ({1} for this system)".FormatWith(
                        StringTools.GetEnglishListPhrase(EmailStatics.GetAdministratorEmailAddresses().Select(i => i.DisplayName), true),
                        "support contacts".ToQuantity(EmailStatics.GetAdministratorEmailAddresses().Count(), showQuantityAs: ShowQuantityAs.None))
                    .ToComponents()
                    .ToFormItem(label: "To".ToComponents()),
                    body.ToTextControl(false, setup: TextControlSetup.Create(numberOfRows: 10), value: "").ToFormItem(label: "Message".ToComponents()));
                ph.AddControlsReturnThis(list.ToCollection().GetControls());

                EwfUiStatics.SetContentFootActions(new ButtonSetup("Send Message").ToCollection());
            });
        }
예제 #2
0
 protected override PageContent getContent() =>
 FormState.ExecuteWithDataModificationsAndDefaultAction(
     PostBack.CreateFull().ToCollection(),
     () => new UiPageContent().Add(
         FormItemList.CreateStack(
             generalSetup: new FormItemListSetup(buttonSetup: new ButtonSetup("Submit")),
             items: getControls().Select((getter, i) => getter((i + 1).ToString())).Materialize())));
예제 #3
0
        protected override PageContent getContent()
        {
            var content = new UiPageContent(isAutoDataUpdater: true);

            var omni = FormItemList.CreateGrid(numberOfColumns: 7);

            var boxId = new ModalBoxId();

            omni.AddFormItems(
                new TextControl("", true).ToFormItem(
                    setup: new FormItemSetup(columnSpan: 2),
                    label: "Model number ".ToComponents()
                    .Append(
                        new EwfButton(
                            new StandardButtonStyle("(popup)", buttonSize: ButtonSize.ShrinkWrap),
                            behavior: new OpenModalBehavior(boxId, etherealChildren: new ModalBox(boxId, true, "More information...".ToComponents()).ToCollection())))
                    .Materialize()),
                "".ToComponents().ToFormItem(label: "Normal price".ToComponents()),
                new TextControl("", true).ToFormItem(label: "Actual price".ToComponents()),
                new TextControl("", true).ToFormItem(label: "Quantity".ToComponents()),
                "".ToComponents().ToFormItem(label: "Inventory".ToComponents()),
                "".ToComponents().ToFormItem(label: "Bill Number".ToComponents()));
            content.Add(omni);

            return(content);
        }
예제 #4
0
        protected override void loadData()
        {
            var staticFil = FormItemList.CreateStack(generalSetup: new FormItemListSetup(buttonSetup: new ButtonSetup("Submit")));

            staticFil.AddFormItems(
                new TextControl("Values here will be retained across post-backs", true).ToFormItem(label: "Static Field".ToComponents()),
                new TextControl("", true).ToFormItem(label: "Static Field".ToComponents()),
                new TextControl(
                    "Edit this one to get a validation error",
                    true,
                    setup: TextControlSetup.Create(validationPredicate: valueChangedOnPostBack => valueChangedOnPostBack),
                    validationMethod: (postBackValue, validator) => validator.NoteErrorAndAddMessage("You can't change the value in this box!")).ToFormItem(
                    label: "Static Field".ToComponents()));
            ph.AddControlsReturnThis(staticFil.ToCollection().GetControls());

            ph.AddControlsReturnThis(getBasicRegionComponents().GetControls());

            var listTable = EwfTable.Create(
                style: EwfTableStyle.StandardLayoutOnly,
                fields: new[] { 10, 1, 10 }.Select(i => new EwfTableField(size: i.ToPercentage())).Materialize());

            listTable.AddItem(
                EwfTableItem.Create(
                    EwfTableItemSetup.Create(verticalAlignment: TableCellVerticalAlignment.Top),
                    getNonIdListRegionComponents().ToCell(),
                    "".ToCell(),
                    getIdListRegionComponents().ToCell()));
            ph.AddControlsReturnThis(listTable.ToCollection().GetControls());
        }
 protected override PageContent getContent() =>
 FormState.ExecuteWithDataModificationsAndDefaultAction(
     PostBack.CreateFull().ToCollection(),
     () => new UiPageContent(contentFootActions: new ButtonSetup("Submit").ToCollection()).Add(
         new Section("Radio Button List, Vertical", FormItemList.CreateStack(items: getRadioItems(false).Materialize()).ToCollection())
         .Append(new Section("Radio Button List, Horizontal", FormItemList.CreateStack(items: getRadioItems(true).Materialize()).ToCollection()))
         .Append(getChosenUpgradeTestingInfo())
         .Append(new Section("Drop-Down List", FormItemList.CreateStack(items: getDropDownItems().Materialize()).ToCollection()))
         .Materialize()));
        protected override PageContent getContent()
        {
            var content = new UiPageContent(omitContentBox: true);

            if (UserManagementStatics.IdentityProviders.OfType <SamlIdentityProvider>().Any())
            {
                var certificate = UserManagementStatics.GetCertificate();
                content.Add(
                    new Section(
                        "Identity providers",
                        FormItemList.CreateStack(
                            items:
                            (certificate.Any()
                                                                          ? "Certificate valid until {0}.".FormatWith(
                                 new X509Certificate2(Convert.FromBase64String(certificate), UserManagementStatics.CertificatePassword).NotAfter
                                 .ToDayMonthYearString(
                                     false))
                             .ToComponents()
                                                                          : "No certificate.".ToComponents()).Concat(" ".ToComponents())
                            .Append(
                                new EwfButton(
                                    new StandardButtonStyle("Regenerate", buttonSize: ButtonSize.ShrinkWrap),
                                    behavior: new ConfirmationButtonBehavior(
                                        "Are you sure?".ToComponents(),
                                        postBack: PostBack.CreateFull(
                                            "certificate",
                                            modificationMethod: () => UserManagementStatics.UpdateCertificate(generateCertificate(DateTimeOffset.UtcNow))))))
                            .Materialize()
                            .ToFormItem(label: "System self-signed certificate".ToComponents())
                            .Concat(
                                AuthenticationStatics.SamlIdentityProviders.Any()
                                                                                ? new EwfHyperlink(EnterpriseWebFramework.UserManagement.SamlResources.Metadata.GetInfo(), new StandardHyperlinkStyle(""))
                                .ToFormItem(label: "Application SAML metadata".ToComponents())
                                .ToCollection()
                                                                                : Enumerable.Empty <FormItem>())
                            .Materialize())
                        .ToCollection(),
                        style: SectionStyle.Box));
            }
            content.Add(
                new Section(
                    "System users",
                    EwfTable.Create(
                        tableActions: new HyperlinkSetup(new SystemUser(Es, null), "Create User").ToCollection(),
                        headItems: EwfTableItem.Create("Email".ToCell().Append("Role".ToCell()).Materialize()).ToCollection())
                    .AddData(
                        UserManagementStatics.SystemProvider.GetUsers(),
                        user => EwfTableItem.Create(
                            user.Email.ToCell().Append(user.Role.Name.ToCell()).Materialize(),
                            setup: EwfTableItemSetup.Create(activationBehavior: ElementActivationBehavior.CreateHyperlink(new SystemUser(Es, user.UserId)))))
                    .ToCollection(),
                    style: SectionStyle.Box));
            return(content);
        }
예제 #7
0
        protected override PageContent getContent()
        {
            var list = FormItemList.CreateStack();

            list.AddFormItems(
                new DateControl(null, true).ToFormItem(label: "Date control".ToComponents()),
                new TimeControl(null, true).ToFormItem(label: "Time control".ToComponents()),
                new TimeControl(null, true, minuteInterval: 30).ToFormItem(label: "Drop-down time control".ToComponents()),
                new DateAndTimeControl(null, true).ToFormItem(label: "Date and time control".ToComponents()),
                new DurationControl(null, true).ToFormItem(label: "Duration control".ToComponents()));
            return(new UiPageContent(isAutoDataUpdater: true).Add(list));
        }
예제 #8
0
        protected override void loadData()
        {
            var list = FormItemList.CreateStack();

            list.AddFormItems(
                new DateControl(null, true).ToFormItem(label: "Date control".ToComponents()),
                new TimeControl(null, true).ToFormItem(label: "Time control".ToComponents()),
                new TimeControl(null, true, minuteInterval: 30).ToFormItem(label: "Drop-down time control".ToComponents()),
                new DateAndTimeControl(null, true).ToFormItem(label: "Date and time control".ToComponents()),
                new DurationControl(null, true).ToFormItem(label: "Duration control".ToComponents()));
            ph.AddControlsReturnThis(list.ToCollection().GetControls());
        }
        protected override PageContent getContent()
        {
            var mod    = getMod();
            var tagIds = ComponentStateItem.Create(
                "tags",
                ArticleId.HasValue
                                        ? ArticleTagsTableRetrieval.GetRowsLinkedToArticle(ArticleId.Value).Select(i => i.TagId).Materialize()
                                        : Enumerable.Empty <int>().Materialize(),
                v => v.All(id => TagsTableRetrieval.GetRowMatchingId(id, returnNullIfNoMatch: true) != null),
                true);

            return(FormState.ExecuteWithDataModificationsAndDefaultAction(
                       PostBack.CreateFull(
                           modificationMethod: () => {
                if (!ArticleId.HasValue)
                {
                    mod.ArticleId = MainSequence.GetNextValue();
                    mod.Slug = getSuffixedSlug(mod.Title.ToUrlSlug());
                    mod.CreationDateAndTime = DateTime.UtcNow;
                }
                mod.Execute();

                if (ArticleId.HasValue)
                {
                    ArticleTagsModification.DeleteRows(new ArticleTagsTableEqualityConditions.ArticleId(ArticleId.Value));
                }
                foreach (var i in tagIds.Value.Value)
                {
                    ArticleTagsModification.InsertRow(mod.ArticleId, i);
                }
            },
                           actionGetter: () => new PostBackAction(Article.GetInfo(mod.ArticleId)))
                       .ToCollection(),
                       () => {
                var stack = FormItemList.CreateStack(generalSetup: new FormItemListSetup(etherealContent: tagIds.ToCollection()));

                stack.AddItems(
                    mod.GetTitleTextControlFormItem(false, label: "Article title".ToComponents(), value: ArticleId.HasValue ? null : "")
                    .Append(
                        mod.GetDescriptionTextControlFormItem(false, label: "What's this article about?".ToComponents(), value: ArticleId.HasValue ? null : ""))
                    .Append(
                        mod.GetBodyMarkdownTextControlFormItem(
                            false,
                            label: "Write your article (in markdown)".ToComponents(),
                            controlSetup: TextControlSetup.Create(numberOfRows: 8),
                            value: ArticleId.HasValue ? null : ""))
                    .Append(getTagFormItem(tagIds.Value))
                    .Materialize());

                return new UiPageContent(contentFootActions: new ButtonSetup("Publish Article").ToCollection()).Add(stack);
            }));
        }
        protected override void loadData()
        {
            FormState.ExecuteWithDataModificationsAndDefaultAction(
                PostBack.CreateFull().ToCollection(),
                () => {
                ph.AddControlsReturnThis(
                    new Section("Radio Button List, Vertical", FormItemList.CreateStack(items: getRadioItems(false).Materialize()).ToCollection())
                    .ToCollection <FlowComponent>()
                    .Append(new Section("Radio Button List, Horizontal", FormItemList.CreateStack(items: getRadioItems(true).Materialize()).ToCollection()))
                    .Append(getChosenUpgradeTestingInfo())
                    .Append(new Section("Drop-Down List", FormItemList.CreateStack(items: getDropDownItems().Materialize()).ToCollection()))
                    .GetControls());

                EwfUiStatics.SetContentFootActions(new ButtonSetup("Submit").ToCollection());
            });
        }
예제 #11
0
 protected override void loadData()
 {
     ph.AddControlsReturnThis(
         FormState.ExecuteWithDataModificationsAndDefaultAction(
             PostBack.CreateFull().ToCollection(),
             () => FormItemList.CreateStack(
                 generalSetup: new FormItemListSetup(buttonSetup: new ButtonSetup("Submit")),
                 items: getControls().Select((getter, i) => getter((i + 1).ToString())).Materialize()))
         .ToCollection <FlowComponent>()
         .Append(
             new Section(
                 "Independent Controls",
                 FormItemList.CreateStack(items: getIndependentControls().Select((getter, i) => getter("I-" + (i + 1).ToString())).Materialize())
                 .ToCollection()))
         .GetControls());
 }
예제 #12
0
        protected override void loadData()
        {
            FormState.ExecuteWithDataModificationsAndDefaultAction(
                PostBack.CreateFull(
                    actionGetter: () => new PostBackAction(
                        new PageReloadBehavior(
                            secondaryResponse: new SecondaryResponse(
                                () => EwfResponse.Create(
                                    ContentTypes.ApplicationZip,
                                    new EwfResponseBodyCreator(createAndZipSystem),
                                    fileNameCreator: () => "{0}.zip".FormatWith(systemShortName.Value))))))
                .ToCollection(),
                () => {
                ph.AddControlsReturnThis(
                    FormItemList.CreateStack(
                        items: new[]
                {
                    systemName.ToTextControl(
                        false,
                        value: "",
                        maxLength: 50,
                        additionalValidationMethod: validator => {
                        if (systemName.Value != systemName.Value.RemoveNonAlphanumericCharacters(preserveWhiteSpace: true))
                        {
                            validator.NoteErrorAndAddMessage("The system name must consist of only alphanumeric characters and white space.");
                        }
                        systemShortName.Value = systemName.Value.EnglishToPascal();
                    })
                    .ToFormItem(label: "System name".ToComponents()),
                    baseNamespace.ToTextControl(
                        false,
                        value: "",
                        maxLength: 50,
                        additionalValidationMethod: validator => {
                        if (baseNamespace.Value != EwlStatics.GetCSharpIdentifier(baseNamespace.Value))
                        {
                            validator.NoteErrorAndAddMessage("The base namespace must be a valid C# identifier.");
                        }
                    })
                    .ToFormItem(label: "Base namespace".ToComponents())
                })
                    .ToCollection()
                    .GetControls());

                EwfUiStatics.SetContentFootActions(new ButtonSetup("Create System").ToCollection());
            });
        }
예제 #13
0
        // 作業項目マスタデータをItemList画面から得る
        private void chooseItemData()
        {
            WorkItemsData wids = FormItemList.ReceiveItems(wid);

            if (wids == null)
            {
                return;
            }

            viewItemDataToDgv(dataGridView1.Rows[dataGridView1.CurrentCellAddress.Y], wids);

            Calculation calc = new Calculation();

            if (calc.ExtractCalcWord(Convert.ToString(dataGridView1.Rows[dataGridView1.CurrentCellAddress.Y].Cells["Item"].Value)) != null)
            {
                verticalCalc();
            }
        }
 protected override void loadData()
 {
     FormState.ExecuteWithDataModificationsAndDefaultAction(
         PostBack.CreateFull(
             firstModificationMethod: modifyData,
             actionGetter: () => new PostBackAction(new ExternalResourceInfo(es.info.ReturnAndDestinationUrl)))
         .ToCollection(),
         () => {
         newPassword = new DataValue <string>();
         ph.AddControlsReturnThis(
             FormItemList.CreateStack(
                 items: newPassword.GetPasswordModificationFormItems(
                     firstLabel: "New password".ToComponents(),
                     secondLabel: "Re-type new password".ToComponents()))
             .ToCollection()
             .GetControls());
         EwfUiStatics.SetContentFootActions(new ButtonSetup("Change Password").ToCollection());
     });
 }
        protected override void loadData()
        {
            if (info.Password.Any())
            {
                if (!pageViewDataModificationsExecuted)
                {
                    throw new ApplicationException("Page-view data modifications did not execute.");
                }

                ph.AddControlsReturnThis(new Paragraph("Please wait.".ToComponents()).ToCollection().GetControls());
                StandardLibrarySessionState.Instance.SetInstantClientSideNavigation(new ExternalResourceInfo(info.ReturnUrl).GetUrl());
                return;
            }

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                PostBack.CreateFull(
                    firstModificationMethod: () => logIn(false),
                    actionGetter: () => new PostBackAction(new ExternalResourceInfo(info.ReturnUrl)))
                .ToCollection(),
                () => {
                ph.AddControlsReturnThis(
                    FormItemList.CreateStack(
                        items: new TextControl(
                            "",
                            true,
                            setup: TextControlSetup.CreateObscured(),
                            validationMethod: (postBackValue, validator) => {
                    // NOTE: Using a single password here is a hack. The real solution is being able to use RSIS credentials, which is a goal.
                    var passwordMatch = postBackValue == ConfigurationStatics.SystemGeneralProvider.IntermediateLogInPassword;
                    if (!passwordMatch)
                    {
                        validator.NoteErrorAndAddMessage("Incorrect password.");
                    }
                }).ToFormItem(label: "Enter your password for this non-live installation".ToComponents())
                        .ToCollection())
                    .ToCollection()
                    .GetControls());

                EwfUiStatics.SetContentFootActions(new ButtonSetup("Log In").ToCollection());
            });
        }
예제 #16
0
        protected override PageContent getContent()
        {
            Action <int> passwordUpdater = null;

            return(FormState.ExecuteWithDataModificationsAndDefaultAction(
                       PostBack.CreateFull(
                           modificationMethod: () => {
                passwordUpdater(AppTools.User.UserId);
                AddStatusMessage(StatusMessageType.Info, "Your password has been successfully changed. Use it the next time you log in.");
            },
                           actionGetter: () => new PostBackAction(new ExternalResource(ReturnAndDestinationUrl)))
                       .ToCollection(),
                       () => new UiPageContent(
                           pageActions: new HyperlinkSetup(new ExternalResource(ReturnAndDestinationUrl), "Back").ToCollection(),
                           contentFootActions: new ButtonSetup("Change Password").ToCollection()).Add(
                           FormItemList.CreateStack(
                               items: AuthenticationStatics.GetPasswordModificationFormItems(
                                   out passwordUpdater,
                                   firstLabel: "New password".ToComponents(),
                                   secondLabel: "Re-type new password".ToComponents())))));
        }
예제 #17
0
        protected override void loadData()
        {
            var omni = FormItemList.CreateGrid(numberOfColumns: 7);

            var boxId = new ModalBoxId();

            new ModalBox(boxId, true, "More information...".ToComponents()).ToCollection().AddEtherealControls(this);

            omni.AddFormItems(
                new TextControl("", true).ToFormItem(
                    setup: new FormItemSetup(columnSpan: 2),
                    label: "Model number ".ToComponents()
                    .Append(new EwfButton(new StandardButtonStyle("(popup)", buttonSize: ButtonSize.ShrinkWrap), behavior: new OpenModalBehavior(boxId)))
                    .Materialize()),
                "".ToComponents().ToFormItem(label: "Normal price".ToComponents()),
                new TextControl("", true).ToFormItem(label: "Actual price".ToComponents()),
                new TextControl("", true).ToFormItem(label: "Quantity".ToComponents()),
                "".ToComponents().ToFormItem(label: "Inventory".ToComponents()),
                "".ToComponents().ToFormItem(label: "Bill Number".ToComponents()));
            ph.AddControlsReturnThis(omni.ToCollection().GetControls());
        }
예제 #18
0
        // 作業項目マスタデータをItemList画面から得る
        private void chooseItemData(DataGridView dgv)
        {
            WorkItemsData wids = FormItemList.ReceiveItems(wid);

            if (wids == null)
            {
                return;
            }

            viewItemDataToDgv(dgv.Rows[dgv.CurrentCellAddress.Y], wids);

            if (wids.Unit != "")
            {
                dgv.CurrentCell = dgv.Rows[dgv.CurrentCellAddress.Y].Cells["Quantity"];
            }

            Calculation calc = new Calculation();

            if (calc.ExtractCalcWord(Convert.ToString(dgv.Rows[dgv.CurrentCellAddress.Y].Cells["Item"].Value)) != null)
            {
                verticalCalc(dgv);
            }
        }
예제 #19
0
        private FlowComponent getFormItemStack(UsersModification mod, DataValue <string> password)
        {
            var stack = FormItemList.CreateStack();

            if (AppTools.User != null)
            {
                stack.AddItem(mod.GetProfilePictureUrlUrlControlFormItem(true, label: "URL of profile picture".ToComponents()));
            }
            stack.AddItem(mod.GetUsernameTextControlFormItem(false, label: "Username".ToComponents(), value: AppTools.User == null ? "" : null));
            if (AppTools.User != null)
            {
                stack.AddItem(
                    mod.GetShortBioTextControlFormItem(true, label: "Short bio about you".ToComponents(), controlSetup: TextControlSetup.Create(numberOfRows: 8)));
            }
            stack.AddItem(mod.GetEmailAddressEmailAddressControlFormItem(false, label: "Email".ToComponents(), value: AppTools.User == null ? "" : null));

            if (AppTools.User == null)
            {
                stack.AddItems(password.GetPasswordModificationFormItems());
            }
            else
            {
                var changePasswordChecked = new DataValue <bool>();
                stack.AddItem(
                    changePasswordChecked.ToFlowCheckbox(
                        "Change password".ToComponents(),
                        setup: FlowCheckboxSetup.Create(
                            nestedContentGetter: () => FormState.ExecuteWithValidationPredicate(
                                () => changePasswordChecked.Value,
                                () => FormItemList.CreateGrid(1, items: password.GetPasswordModificationFormItems()).ToCollection())),
                        value: false)
                    .ToFormItem());
            }

            return(stack);
        }
예제 #20
0
        protected override PageContent getContent()
        {
            var content = new UiPageContent(isAutoDataUpdater: true);

            var fil = FormItemList.CreateStack();

            fil.AddFormItems(parametersModification.GetField1TextControlFormItem(true), parametersModification.GetField2TextControlFormItem(true));
            content.Add(fil);

            content.Add(
                new EwfButton(
                    new StandardButtonStyle("Navigate and change Field 2"),
                    behavior: new PostBackBehavior(
                        postBack: PostBack.CreateFull(
                            actionGetter: () => new PostBackAction(
                                new OptionalParametersDemo(Es, optionalParameterSetter: (specifier, entitySetup, parameters) => { specifier.Field2 = "bob"; }))))));

            var table = EwfTable.Create(headItems: new[] { EwfTableItem.Create("Url".ToCell(), "Valid?".ToCell()) });

            content.Add(table);

            foreach (var scheme in new[] { "http://", "ftp://", "file://" })
            {
                foreach (var userinfo in new[] { "", "user:pass@" })
                {
                    foreach (var subdomain in new[] { "", "subdomain." })
                    {
                        foreach (var domain in new[] { "domain", "localhost" })
                        {
                            foreach (var tld in new[] { "", ".com" })
                            {
                                foreach (var port in new[] { "", ":80" })
                                {
                                    foreach (var folder in new[] { "", "/", "/folder/" })
                                    {
                                        foreach (var file in new[] { "", "file.asp" })
                                        {
                                            foreach (var query in new[] { "", "?here=go&there=yup" })
                                            {
                                                foreach (var frag in new[] { "", "#fragment" })
                                                {
                                                    testUrl(table, scheme + userinfo + subdomain + domain + tld + port + folder + file + query + frag);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                foreach (var additionalUrl in new[]
                {
                    "//example.org/scheme-relative/URI/with/absolute/path/to/resource.txt", "/relative/URI/with/absolute/path/to/resource.txt",
                    "relative/path/to/resource.txt", "../../../resource.txt", "./resource.txt#frag01", "resource.txt", "#frag01", "www.world.com"
                })
                {
                    testUrl(table, additionalUrl);
                }
            }

            return(content);
        }
        protected override void loadData()
        {
            var fil = FormItemList.CreateStack();

            fil.AddFormItems(parametersModification.GetField1TextControlFormItem(true), parametersModification.GetField2TextControlFormItem(true));
            ph.AddControlsReturnThis(fil.ToCollection().GetControls());

            ph.AddControlsReturnThis(
                new EwfButton(
                    new StandardButtonStyle("Navigate and change Field 2"),
                    behavior: new PostBackBehavior(
                        postBack: PostBack.CreateFull(
                            actionGetter: () => new PostBackAction(new Info(es.info, new OptionalParameterPackage {
                Field2 = "bob"
            })))))
                .ToCollection()
                .GetControls());

            var table = EwfTable.Create(headItems: new[] { EwfTableItem.Create("Url".ToCell(), "Valid?".ToCell()) });

            ph.AddControlsReturnThis(table.ToCollection().GetControls());

            foreach (var scheme in new[] { "http://", "ftp://", "file://" })
            {
                foreach (var userinfo in new[] { "", "user:pass@" })
                {
                    foreach (var subdomain in new[] { "", "subdomain." })
                    {
                        foreach (var domain in new[] { "domain", "localhost" })
                        {
                            foreach (var tld in new[] { "", ".com" })
                            {
                                foreach (var port in new[] { "", ":80" })
                                {
                                    foreach (var folder in new[] { "", "/", "/folder/" })
                                    {
                                        foreach (var file in new[] { "", "file.asp" })
                                        {
                                            foreach (var query in new[] { "", "?here=go&there=yup" })
                                            {
                                                foreach (var frag in new[] { "", "#fragment" })
                                                {
                                                    testUrl(table, scheme + userinfo + subdomain + domain + tld + port + folder + file + query + frag);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                foreach (var additionalUrl in new[]
                {
                    "//example.org/scheme-relative/URI/with/absolute/path/to/resource.txt", "/relative/URI/with/absolute/path/to/resource.txt",
                    "relative/path/to/resource.txt", "../../../resource.txt", "./resource.txt#frag01", "resource.txt", "#frag01", "www.world.com"
                })
                {
                    testUrl(table, additionalUrl);
                }
            }
        }
        void ControlTreeDataLoader.LoadData()
        {
            basicBody.Attributes.Add("onpagehide", "deactivateProcessingDialog();");
            form.Action = EwfPage.Instance.InfoAsBaseType.GetUrl();

            ph.AddControlsReturnThis(
                new NamingPlaceholder(
                    EwfPage.Instance.StatusMessages.Any() && statusMessagesDisplayAsNotification()
                                                ? new Block {
                CssClass = notificationSpacerClass
            }.ToCollection()
                                                : Enumerable.Empty <Control>()));

            var warningLines = new List <IReadOnlyCollection <PhrasingComponent> >();

            if (!ConfigurationStatics.IsLiveInstallation)
            {
                var components = new List <PhrasingComponent>();
                components.Add(new FontAwesomeIcon("fa-exclamation-triangle", "fa-lg"));
                components.AddRange(" This is not the live system. Changes made here will be lost and are not recoverable. ".ToComponents());
                if (ConfigurationStatics.IsIntermediateInstallation && AppRequestState.Instance.IntermediateUserExists)
                {
                    components.AddRange(
                        new EwfButton(
                            new StandardButtonStyle("Log out", buttonSize: ButtonSize.ShrinkWrap),
                            behavior: new PostBackBehavior(
                                postBack: PostBack.CreateFull(
                                    id: "ewfIntermediateLogOut",
                                    firstModificationMethod: NonLiveInstallationStatics.ClearIntermediateAuthenticationCookie,
                                    actionGetter: () => new PostBackAction(new ExternalResourceInfo(NetTools.HomeUrl))))).Concat(" ".ToComponents()));
                }
                components.Add(
                    new EwfButton(
                        new StandardButtonStyle(
                            "Hide this warning",
                            buttonSize: ButtonSize.ShrinkWrap,
                            icon: new ActionComponentIcon(new FontAwesomeIcon("fa-eye-slash"))),
                        behavior: new PostBackBehavior(
                            postBack: PostBack.CreateIntermediate(
                                null,
                                id: "ewfHideNonLiveWarnings",
                                firstModificationMethod: NonLiveInstallationStatics.SetWarningsHiddenCookie))));
                if (ConfigurationStatics.IsIntermediateInstallation && AppRequestState.Instance.IntermediateUserExists)
                {
                    var boxId = new ModalBoxId();
                    components.AddRange(
                        " ".ToComponents()
                        .Append(
                            new EwfButton(
                                new StandardButtonStyle("Get link", buttonSize: ButtonSize.ShrinkWrap, icon: new ActionComponentIcon(new FontAwesomeIcon("fa-link"))),
                                behavior: new OpenModalBehavior(
                                    boxId,
                                    etherealChildren: new ModalBox(
                                        boxId,
                                        true,
                                        FormItemList.CreateGrid(
                                            1,
                                            items: new[] { false, true }.Select(
                                                i => {
                        var url = AppRequestState.Instance.Url;
                        if (AppRequestState.Instance.UserAccessible && AppRequestState.Instance.ImpersonatorExists)
                        {
                            url = SelectUser.GetInfo(
                                url,
                                optionalParameterPackage: new SelectUser.OptionalParameterPackage {
                                User = AppTools.User.Email
                            })
                                  .GetUrl();
                        }
                        url = IntermediateLogIn.GetInfo(
                            url,
                            new IntermediateLogIn.OptionalParameterPackage
                        {
                            Password = ConfigurationStatics.SystemGeneralProvider.IntermediateLogInPassword, HideWarnings = i
                        })
                              .GetUrl();
                        return(new GenericPhrasingContainer(
                                   url.ToComponents(),
                                   classes: new ElementClass("ewfIntermediateUrl" /* This is used by EWF CSS files. */)).ToFormItem(
                                   label: i ? "Non-live warnings hidden:".ToComponents() : "Standard:".ToComponents()));
                    })
                                            .Materialize())
                                        .ToCollection()).ToCollection()))));
                }
                warningLines.Add(components);
            }

            if (AppRequestState.Instance.UserAccessible && AppRequestState.Instance.ImpersonatorExists &&
                (!ConfigurationStatics.IsIntermediateInstallation || AppRequestState.Instance.IntermediateUserExists))
            {
                warningLines.Add(
                    "User impersonation is in effect. ".ToComponents()
                    .Append(
                        new EwfHyperlink(
                            SelectUser.GetInfo(AppRequestState.Instance.Url),
                            new ButtonHyperlinkStyle("Change user", buttonSize: ButtonSize.ShrinkWrap)))
                    .Concat(" ".ToComponents())
                    .Append(
                        new EwfButton(
                            new StandardButtonStyle("End impersonation", buttonSize: ButtonSize.ShrinkWrap),
                            behavior: new PostBackBehavior(
                                postBack: PostBack.CreateFull(
                                    id: "ewfEndImpersonation",
                                    firstModificationMethod: UserImpersonationStatics.EndImpersonation,
                                    actionGetter: () => new PostBackAction(new ExternalResourceInfo(NetTools.HomeUrl))))))
                    .Materialize());
            }

            if (warningLines.Any())
            {
                ph.AddControlsReturnThis(
                    new GenericFlowContainer(
                        warningLines.Aggregate((components, line) => components.Append(new LineBreak()).Concat(line).Materialize()),
                        displaySetup: new DisplaySetup(ConfigurationStatics.IsLiveInstallation || !NonLiveInstallationStatics.WarningsHiddenCookieExists()),
                        classes: topWarningContainerClass).ToCollection()
                    .GetControls());
            }

            // This is used by the EWF JavaScript file.
            const string clickBlockerId = "ewfClickBlocker";

            ph2.AddControlsReturnThis(
                new Block {
                ClientIDMode = ClientIDMode.Static, ID = clickBlockerId, CssClass = clickBlockerInactiveClass
            },
                new PlaceHolder().AddControlsReturnThis(getProcessingDialog().GetControls()),
                new NamingPlaceholder(getStatusMessageControl()));
        }
        protected override void loadData()
        {
            EwfUiStatics.OmitContentBox();

            Tuple <IReadOnlyCollection <EtherealComponent>, Func <FormsAuthCapableUser> > logInHiddenFieldsAndMethod = null;
            var logInPb = PostBack.CreateFull(
                firstModificationMethod: () => user = logInHiddenFieldsAndMethod.Item2(),
                actionGetter: () => new PostBackAction(
                    user.MustChangePassword ? ChangePassword.Page.GetInfo(info.ReturnUrl) as ResourceInfo : new ExternalResourceInfo(info.ReturnUrl)));
            var newPasswordPb = PostBack.CreateFull(id: "newPw", actionGetter: getSendNewPasswordAction);

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                logInPb.ToCollection(),
                () => {
                var registeredComponents = new List <FlowComponent>();
                registeredComponents.Add(
                    new Paragraph(
                        "You may log in to this system if you have registered your email address with {0}"
                        .FormatWith(FormsAuthStatics.SystemProvider.AdministratingCompanyName)
                        .ToComponents()));

                emailAddress = new DataValue <string>();
                var password = new DataValue <string>();
                registeredComponents.Add(
                    FormItemList.CreateStack(
                        generalSetup: new FormItemListSetup(buttonSetup: new ButtonSetup("Log In"), enableSubmitButton: true),
                        items: FormState
                        .ExecuteWithDataModificationsAndDefaultAction(
                            new[] { logInPb, newPasswordPb },
                            () => emailAddress.GetEmailAddressFormItem("Email address".ToComponents()))
                        .Append(
                            password.ToTextControl(true, setup: TextControlSetup.CreateObscured(autoFillTokens: "current-password"), value: "")
                            .ToFormItem(label: "Password".ToComponents()))
                        .Materialize()));

                if (FormsAuthStatics.PasswordResetEnabled)
                {
                    registeredComponents.Add(
                        new Paragraph(
                            new ImportantContent("Forgot password?".ToComponents()).ToCollection()
                            .Concat(" ".ToComponents())
                            .Append(
                                new EwfButton(
                                    new StandardButtonStyle("Send me a new password", buttonSize: ButtonSize.ShrinkWrap),
                                    behavior: new PostBackBehavior(postBack: newPasswordPb)))
                            .Materialize()));
                }

                ph.AddControlsReturnThis(
                    new FlowAutofocusRegion(
                        AutofocusCondition.InitialRequest(),
                        new Section("Registered users", registeredComponents, style: SectionStyle.Box).ToCollection()).ToCollection()
                    .GetControls());

                logInHiddenFieldsAndMethod = FormsAuthStatics.GetLogInHiddenFieldsAndMethod(
                    emailAddress,
                    password,
                    getUnregisteredEmailMessage(),
                    "Incorrect password. If you do not know your password, enter your email address and send yourself a new password using the link below.");
                logInHiddenFieldsAndMethod.Item1.AddEtherealControls(this);
            });

            var specialInstructions = EwfUiStatics.AppProvider.GetSpecialInstructionsForLogInPage();

            if (specialInstructions != null)
            {
                ph.AddControlsReturnThis(specialInstructions);
            }
            else
            {
                var unregisteredComponents = new List <FlowComponent>();
                unregisteredComponents.Add(
                    new Paragraph("If you have difficulty logging in, please {0}".FormatWith(FormsAuthStatics.SystemProvider.LogInHelpInstructions).ToComponents()));
                ph.AddControlsReturnThis(new Section("Unregistered users", unregisteredComponents, style: SectionStyle.Box).ToCollection().GetControls());
            }
        }
예제 #24
0
        protected override PageContent getContent()
        {
            AuthenticationStatics.CodeLoginModificationMethod codeLoginMethod = null;
            string destinationUrl = null;

            if (User.Any())
            {
                var postBack = PostBack.CreateFull(
                    modificationMethod: () => destinationUrl = codeLoginMethod(
                        User,
                        Code,
                        errorMessage:
                        "The login link you just used has expired. Please return to the page you were trying to access and send yourself another login email.")
                                                               .destinationUrl,
                    actionGetter: () => new PostBackAction(new ExternalResource(destinationUrl)));
                return(FormState.ExecuteWithDataModificationsAndDefaultAction(
                           postBack.ToCollection(),
                           () => {
                    var logInHiddenFieldsAndMethods = AuthenticationStatics.GetLogInHiddenFieldsAndMethods();
                    codeLoginMethod = logInHiddenFieldsAndMethods.modificationMethods.codeLoginMethod;
                    return new UiPageContent(pageLoadPostBack: postBack).Add(new Paragraph("Please wait.".ToComponents()))
                    .Add(logInHiddenFieldsAndMethods.hiddenFields);
                }));
            }

            var content = new UiPageContent(omitContentBox: true);

            var codeEntryIsForPasswordReset = ComponentStateItem.Create <bool?>("codeEntryIsForPasswordReset", null, value => true, false);

            var emailAddress = new DataValue <string>();
            var password     = new DataValue <string>();
            var loginCode    = new DataValue <string>();

            AuthenticationStatics.PasswordLoginModificationMethod passwordLoginMethod = null;
            AuthenticationStatics.LoginCodeSenderMethod           loginCodeSender     = null;

            var logInPb = PostBack.CreateFull(
                modificationMethod: () => {
                if (codeEntryIsForPasswordReset.Value.Value.HasValue)
                {
                    destinationUrl = codeLoginMethod(emailAddress.Value, loginCode.Value).destinationUrl;
                }
                else
                {
                    passwordLoginMethod(emailAddress, password);
                }
            },
                actionGetter: () => new PostBackAction(new ExternalResource(codeEntryIsForPasswordReset.Value.Value.HasValue ? destinationUrl : ReturnUrl)));

            var          authenticationModeUpdateRegion = new UpdateRegionSet();
            const string passwordOrCodeFocusKey         = "code";
            var          sendCodePb = codeEntryIsForPasswordReset.Value.Value != true
                                                 ? PostBack.CreateIntermediate(
                authenticationModeUpdateRegion.ToCollection(),
                id : "sendCode",
                modificationMethod : () => {
                loginCodeSender(emailAddress, false, ReturnUrl);
                codeEntryIsForPasswordReset.Value.Value = false;
            },
                reloadBehaviorGetter : () => new PageReloadBehavior(focusKey: passwordOrCodeFocusKey))
                                                 : null;

            var newPasswordPb = codeEntryIsForPasswordReset.Value.Value != false
                                                    ? PostBack.CreateIntermediate(
                authenticationModeUpdateRegion.ToCollection(),
                id : "newPw",
                modificationMethod : () => {
                loginCodeSender(emailAddress, true, ReturnUrl);
                codeEntryIsForPasswordReset.Value.Value = true;
            },
                reloadBehaviorGetter : () => new PageReloadBehavior(focusKey: passwordOrCodeFocusKey))
                                                    : null;

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                logInPb.ToCollection(),
                () => {
                var registeredComponents = new List <FlowComponent>();
                registeredComponents.Add(
                    new Paragraph(
                        "You may log in to this system if you have registered your email address with {0}."
                        .FormatWith(UserManagementStatics.LocalIdentityProvider.AdministratingOrganizationName)
                        .ToComponents()));

                registeredComponents.Add(
                    FormItemList.CreateStack(
                        generalSetup: new FormItemListSetup(buttonSetup: new ButtonSetup("Log In"), enableSubmitButton: true),
                        items: FormState
                        .ExecuteWithDataModificationsAndDefaultAction(
                            new[] { logInPb, sendCodePb, newPasswordPb }.Where(i => i != null),
                            () => emailAddress.GetEmailAddressFormItem("Email address".ToComponents()))
                        .Append(
                            codeEntryIsForPasswordReset.Value.Value.HasValue
                                                                                ? getLoginCodeFormItem(authenticationModeUpdateRegion.ToCollection(), AutofocusCondition.PostBack(passwordOrCodeFocusKey), loginCode)
                                                                                : getPasswordFormItem(
                                authenticationModeUpdateRegion.ToCollection(),
                                AutofocusCondition.PostBack(passwordOrCodeFocusKey),
                                password,
                                new PostBackBehavior(postBack: sendCodePb)))
                        .Materialize()));

                registeredComponents.Add(
                    new Paragraph(
                        new PhrasingIdContainer(
                            codeEntryIsForPasswordReset.Value.Value.HasValue
                                                                        ? new ImportantContent("Having trouble?".ToComponents()).ToCollection()
                            .Concat(" ".ToComponents())
                            .Append(
                                new EwfButton(
                                    new StandardButtonStyle("Send me another code", buttonSize: ButtonSize.ShrinkWrap),
                                    behavior: new PostBackBehavior(postBack: codeEntryIsForPasswordReset.Value.Value.Value ? newPasswordPb : sendCodePb)))
                            .Concat(" ".ToComponents())
                            .Append(
                                new EwfButton(
                                    new StandardButtonStyle(
                                        codeEntryIsForPasswordReset.Value.Value.Value ? "Try password again" : "Log in with password",
                                        buttonSize: ButtonSize.ShrinkWrap),
                                    behavior: new PostBackBehavior(
                                        postBack: PostBack.CreateIntermediate(
                                            authenticationModeUpdateRegion.ToCollection(),
                                            id: "revertToPasswordEntry",
                                            modificationMethod: () => codeEntryIsForPasswordReset.Value.Value = null,
                                            reloadBehaviorGetter: () => new PageReloadBehavior(focusKey: passwordOrCodeFocusKey)))))
                                                                        : new ImportantContent("Forgot password?".ToComponents()).ToCollection()
                            .Concat(" ".ToComponents())
                            .Append(
                                new EwfButton(
                                    new StandardButtonStyle("Set a new password", buttonSize: ButtonSize.ShrinkWrap),
                                    behavior: new ConfirmationButtonBehavior(
                                        new Paragraph("Are you sure you want to set a new password?".ToComponents()).Append(
                                            new Paragraph(
                                                StringTools.ConcatenateWithDelimiter(
                                                    " ",
                                                    "Click \"Continue\" to email yourself a login code.",
                                                    "After logging in, you will be prompted to change your password to something you will remember, which you may use to log in from that point forward.")
                                                .ToComponents()))
                                        .Materialize(),
                                        postBack: newPasswordPb))),
                            updateRegionSets: authenticationModeUpdateRegion.ToCollection()).ToCollection()));

                var logInHiddenFieldsAndMethods = FormState.ExecuteWithDataModificationsAndDefaultAction(
                    new[] { logInPb, sendCodePb, newPasswordPb }.Where(i => i != null),
                    AuthenticationStatics.GetLogInHiddenFieldsAndMethods);

                content.Add(
                    new FlowAutofocusRegion(
                        AutofocusCondition.InitialRequest(),
                        new Section(
                            "Registered users",
                            registeredComponents,
                            style: SectionStyle.Box,
                            etherealContent: logInHiddenFieldsAndMethods.hiddenFields.Append(codeEntryIsForPasswordReset).Materialize()).ToCollection()));

                passwordLoginMethod = logInHiddenFieldsAndMethods.modificationMethods.passwordLoginMethod;
                loginCodeSender     = logInHiddenFieldsAndMethods.modificationMethods.loginCodeSender;
                codeLoginMethod     = logInHiddenFieldsAndMethods.modificationMethods.codeLoginMethod;
            });

            var specialInstructions = EwfUiStatics.AppProvider.GetSpecialInstructionsForLogInPage();

            if (specialInstructions.Any())
            {
                content.Add(specialInstructions);
            }
            else
            {
                var unregisteredComponents = new List <FlowComponent>();
                unregisteredComponents.Add(
                    new Paragraph(
                        "If you have difficulty logging in, please {0}".FormatWith(UserManagementStatics.LocalIdentityProvider.LogInHelpInstructions).ToComponents()));
                content.Add(new Section("Unregistered users", unregisteredComponents, style: SectionStyle.Box));
            }

            return(content);
        }
        /// <summary>
        /// Creates a user editor.
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="modificationMethod"></param>
        /// <param name="availableRoles">Pass a restricted list of <see cref="Role"/>s the user may select. Otherwise, Roles available in the System Provider are
        /// used.</param>
        /// <param name="userInserterOrUpdater">A function that takes the validated data, inserts or updates the user, and returns the user’s ID. Pass null to have
        /// the user-management provider handle the insert or update.</param>
        public UserEditor(
            int?userId, out Action modificationMethod, List <Role> availableRoles = null, UserInserterOrUpdaterMethod userInserterOrUpdater = null)
        {
            availableRoles = (availableRoles?.OrderBy(r => r.Name) ?? UserManagementStatics.SystemProvider.GetRoles()).ToList();

            var user = userId.HasValue ? UserManagementStatics.GetUser(userId.Value, true) : null;

            var          email           = new DataValue <string>();
            var          roleId          = new DataValue <int>();
            Action <int> passwordUpdater = null;

            var b = FormItemList.CreateStack();

            b.AddItems(
                email.ToEmailAddressControl(false, value: user != null ? user.Email : "")
                .ToFormItem(label: "Email address".ToComponents())
                .Append(
                    roleId.ToDropDown(
                        DropDownSetup.Create(from i in availableRoles select SelectListItem.Create((int?)i.RoleId, i.Name)),
                        value: new SpecifiedValue <int?>(user?.Role.RoleId))
                    .ToFormItem(label: "Role".ToComponents()))
                .Materialize());

            if (UserManagementStatics.LocalIdentityProviderEnabled)
            {
                var group = new RadioButtonGroup(false);
                var providePasswordSelected = new DataValue <bool>();
                b.AddFormItems(
                    new StackList(
                        group.CreateRadioButton(true, label: userId.HasValue ? "Keep the current password".ToComponents() : "Do not create a password".ToComponents())
                        .ToFormItem()
                        .ToListItem()
                        .Append(
                            providePasswordSelected.ToFlowRadioButton(
                                group,
                                "Provide a {0}".FormatWith(userId.HasValue ? "new password" : "password").ToComponents(),
                                setup: FlowRadioButtonSetup.Create(
                                    nestedContentGetter: () => {
                    return(FormState.ExecuteWithValidationPredicate(
                               () => providePasswordSelected.Value,
                               () => FormItemList.CreateStack(
                                   generalSetup: new FormItemListSetup(classes: new ElementClass("newPassword")),
                                   items: AuthenticationStatics.GetPasswordModificationFormItems(out passwordUpdater))
                               .ToCollection()));
                }),
                                value: false)
                            .ToFormItem()
                            .ToListItem())).ToFormItem(label: "Password".ToComponents()));
            }

            children = new Section("Security Information", b.ToCollection()).ToCollection();

            modificationMethod = () => {
                if (userInserterOrUpdater != null)
                {
                    userId = userInserterOrUpdater(email, roleId);
                }
                else
                {
                    userId = UserManagementStatics.SystemProvider.InsertOrUpdateUser(userId, email.Value, roleId.Value, user?.LastRequestTime);
                }
                passwordUpdater?.Invoke(userId.Value);
            };
        }
        /// <summary>
        /// Call this during LoadData.
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="availableRoles">Pass a restricted list of <see cref="Role"/>s the user may select. Otherwise, Roles available
        /// in the System Provider are used.</param>
        public void LoadData(int?userId, List <Role> availableRoles = null)
        {
            availableRoles = (availableRoles?.OrderBy(r => r.Name) ?? UserManagementStatics.SystemProvider.GetRoles()).ToList();

            var user    = userId.HasValue ? UserManagementStatics.GetUser(userId.Value, true) : null;
            var facUser = includePasswordControls() && user != null?FormsAuthStatics.GetUser(user.UserId, true) : null;

            var b = FormItemList.CreateStack();

            b.AddFormItems(Email.ToEmailAddressControl(false, value: user != null ? user.Email : "").ToFormItem(label: "Email address".ToComponents()));

            if (includePasswordControls())
            {
                var group = new RadioButtonGroup(false);

                var keepPassword = group.CreateRadioButton(
                    true,
                    label: userId.HasValue ? "Keep the current password".ToComponents() : "Do not create a password".ToComponents(),
                    validationMethod: (postBackValue, validator) => {
                    if (!postBackValue.Value)
                    {
                        return;
                    }
                    if (user != null)
                    {
                        Salt.Value               = facUser.Salt;
                        SaltedPassword.Value     = facUser.SaltedPassword;
                        MustChangePassword.Value = facUser.MustChangePassword;
                    }
                    else
                    {
                        genPassword(false);
                    }
                })
                                   .ToFormItem();

                var generatePassword = group.CreateRadioButton(
                    false,
                    label: "Generate a {0} password and email it to the user".FormatWith(userId.HasValue ? "new, random" : "random").ToComponents(),
                    validationMethod: (postBackValue, validator) => {
                    if (postBackValue.Value)
                    {
                        genPassword(true);
                    }
                })
                                       .ToFormItem();

                var providePasswordSelected = new DataValue <bool>();
                var providePassword         = group.CreateFlowRadioButton(
                    false,
                    label: "Provide a {0}".FormatWith(userId.HasValue ? "new password" : "password").ToComponents(),
                    setup: FlowRadioButtonSetup.Create(
                        nestedContentGetter: () => {
                    return(FormState.ExecuteWithValidationPredicate(
                               () => providePasswordSelected.Value,
                               () => {
                        var password = new DataValue <string>();
                        var list = FormItemList.CreateStack(
                            generalSetup: new FormItemListSetup(classes: new ElementClass("newPassword")),
                            items: password.GetPasswordModificationFormItems());

                        new EwfValidation(
                            validator => {
                            var p = new Password(password.Value);
                            Salt.Value = p.Salt;
                            SaltedPassword.Value = p.ComputeSaltedHash();
                            MustChangePassword.Value = false;
                        });

                        return list.ToCollection();
                    }));
                }),
                    validationMethod: (postBackValue, validator) => providePasswordSelected.Value = postBackValue.Value)
                                              .ToFormItem();

                b.AddFormItems(
                    new StackList(keepPassword.ToListItem().ToCollection().Append(generatePassword.ToListItem()).Append(providePassword.ToListItem())).ToFormItem(
                        label: "Password".ToComponents()));
            }

            b.AddFormItems(
                RoleId.ToDropDown(
                    DropDownSetup.Create(from i in availableRoles select SelectListItem.Create(i.RoleId as int?, i.Name)),
                    value: new SpecifiedValue <int?>(user?.Role.RoleId))
                .ToFormItem(label: "Role".ToComponents()));

            this.AddControlsReturnThis(new Section("Security Information", b.ToCollection()).ToCollection().GetControls());
        }