예제 #1
0
        /// <summary>
        /// Save the user's data into the database using the Entity Framework
        /// </summary>
        /// <param name="wizard">The wizard that took the user's details</param>
        protected void PersistUserData(CreateUserWizard wizard)
        {
            TextBox FirstNameInput = wizard.CreateUserStep.ContentTemplateContainer.FindControl("FirstName") as TextBox;
            TextBox LastNameInput = wizard.CreateUserStep.ContentTemplateContainer.FindControl("LastName") as TextBox;

            using (DMSContext database = new DMSContext())
            {
                // Check whether this user already exists first...
                // Create a new row if it doesn't exist or update the old one if it does.
                var existingUser = database.Users.SingleOrDefault(
                    u => u.UserName == wizard.UserName);
                if (existingUser == null)
                {
                    User user = new User();
                    user.UserName = wizard.UserName;
                    user.Email = wizard.Email;
                    user.FirstName = FirstNameInput.Text;
                    user.LastName = LastNameInput.Text;

                    database.Users.Add(user);
                    database.SaveChanges();
                }
                else
                {
                    existingUser.UserName = wizard.UserName;
                    existingUser.Email = wizard.Email;
                    existingUser.FirstName = FirstNameInput.Text;
                    existingUser.LastName = LastNameInput.Text;
                    database.SaveChanges();
                }
            }
        }
예제 #2
0
        private void SendWelcomeEmail(CreateUserWizard c)
        {
            var message = new MailMessage
            {
                From = new MailAddress(FromEmailAddress),
                Subject = "Welcome to PhishMarket",
                IsBodyHtml = false
            };

            message.To.Add(new MailAddress(c.Email));
            message.CC.Add(new MailAddress(CarbonCopyEmailAddress));

            message.Body = SetBody(c.UserName, c.Password);

            var client = new SmtpClient();

            client.Send(message);
        }
			public CompleteStepContainer (CreateUserWizard createUserWizard)
				: base (createUserWizard)
			{
				_createUserWizard = createUserWizard;
			}
			public CreateUserNavigationContainer (CreateUserWizard createUserWizard)
				: base (createUserWizard)
			{
				_createUserWizard = createUserWizard;
			}
 private void WriteContinuePanel(HtmlTextWriter writer, CreateUserWizard wizard)
 {
     string id = "ContinueButton";
     string idWithType = WebControlAdapterExtender.MakeIdWithButtonType(id, wizard.ContinueButtonType);
     Control btn = wizard.FindControl("CompleteStepContainer").FindControl(idWithType);
     if (btn != null)
     {
         Page.ClientScript.RegisterForEventValidation(btn.UniqueID);
         WebControlAdapterExtender.WriteBeginDiv(writer, "AspNet-CreateUserWizard-ContinuePanel");
         Extender.WriteSubmit(writer, wizard.ContinueButtonType, wizard.ContinueButtonStyle.CssClass, "CompleteStepContainer_ContinueButton", wizard.ContinueButtonImageUrl, "", wizard.ContinueButtonText);
         WebControlAdapterExtender.WriteEndDiv(writer);
     }
 }
        private void WriteCreateUserButtonPanel(HtmlTextWriter writer, CreateUserWizard wizard)
        {
            Control btnParentCtrl = wizard.FindControl("__CustomNav0");
            if (btnParentCtrl != null)
            {
                string id = "_CustomNav0_StepNextButton";
                string idWithType = WebControlAdapterExtender.MakeIdWithButtonType("StepNextButton", wizard.CreateUserButtonType);
                Control btn = btnParentCtrl.FindControl(idWithType);
                if (btn != null)
                {
                    Page.ClientScript.RegisterForEventValidation(btn.UniqueID);

                    PostBackOptions options = new PostBackOptions(btn, "", "", false, false, false, false, true, wizard.ID);
                    string javascript = "javascript:" + Page.ClientScript.GetPostBackEventReference(options);
                    javascript = Page.Server.HtmlEncode(javascript);

                    WebControlAdapterExtender.WriteBeginDiv(writer, "AspNet-CreateUserWizard-CreateUserButtonPanel");

                    Extender.WriteSubmit(writer, wizard.CreateUserButtonType, wizard.CreateUserButtonStyle.CssClass, id, wizard.CreateUserButtonImageUrl, javascript, wizard.CreateUserButtonText);

                    if (wizard.DisplayCancelButton)
                    {
                        Extender.WriteSubmit(writer, wizard.CancelButtonType, wizard.CancelButtonStyle.CssClass, "_CustomNav0_CancelButton", wizard.CancelButtonImageUrl, "", wizard.CancelButtonText);
                    }

                    WebControlAdapterExtender.WriteEndDiv(writer);
                }
            }
        }
        private void WriteAnswerPanel(HtmlTextWriter writer, CreateUserWizard wizard)
        {
            if ((WizardMembershipProvider != null) && WizardMembershipProvider.RequiresQuestionAndAnswer)
            {
                TextBox textBox = wizard.FindControl("CreateUserStepContainer").FindControl("Answer") as TextBox;
                if (textBox != null)
                {
                    Page.ClientScript.RegisterForEventValidation(textBox.UniqueID);

                    WebControlAdapterExtender.WriteBeginDiv(writer, "AspNet-CreateUserWizard-AnswerPanel");
                    Extender.WriteTextBox(writer, false, wizard.LabelStyle.CssClass, wizard.AnswerLabelText, wizard.TextBoxStyle.CssClass, "CreateUserStepContainer_Answer", "");
                    WebControlAdapterExtender.WriteRequiredFieldValidator(writer, wizard.FindControl("CreateUserStepContainer").FindControl("AnswerRequired") as RequiredFieldValidator, wizard.ValidatorTextStyle.CssClass, "Answer", wizard.AnswerRequiredErrorMessage);
                    WebControlAdapterExtender.WriteEndDiv(writer);
                }
            }
        }
 private void WritePasswordHintPanel(HtmlTextWriter writer, CreateUserWizard wizard)
 {
     if (!String.IsNullOrEmpty(wizard.PasswordHintText))
     {
         WebControlAdapterExtender.WriteBeginDiv(writer, "AspNet-CreateUserWizard-PasswordHintPanel");            
         WebControlAdapterExtender.WriteSpan(writer, "", wizard.PasswordHintText);
         WebControlAdapterExtender.WriteEndDiv(writer);
     }
 }
 private static void AddTitleRow(Table table, CreateUserWizard.CreateUserStepContainer container)
 {
     TableRow row = CreateUserWizard.CreateDoubleSpannedColumnRow(2, new Control[] { container.Title });
     table.Rows.Add(row);
 }
 private void AddPasswordRow(Table table, CreateUserWizard.CreateUserStepContainer container)
 {
     if (this._wizard.ConvertingToTemplate)
     {
         container.PasswordLabel.RenderAsLabel = true;
     }
     List<Control> list = new List<Control> {
         container.PasswordTextBox
     };
     if (!this._wizard.AutoGeneratePassword)
     {
         list.Add(container.PasswordRequired);
     }
     TableRow row = CreateUserWizard.CreateTwoColumnRow(container.PasswordLabel, list.ToArray());
     this._wizard._passwordTableRow = row;
     table.Rows.Add(row);
 }
 private void AddPasswordRegexValidatorRow(Table table, CreateUserWizard.CreateUserStepContainer container)
 {
     TableRow row = CreateUserWizard.CreateDoubleSpannedColumnRow(2, new Control[] { container.PasswordRegExpValidator });
     this._wizard._passwordRegExpRow = row;
     table.Rows.Add(row);
 }
 private void AddPasswordHintRow(Table table, CreateUserWizard.CreateUserStepContainer container)
 {
     TableRow row = CreateUserWizard.CreateTableRow();
     TableCell cell = CreateUserWizard.CreateTableCell();
     row.Cells.Add(cell);
     TableCell cell2 = CreateUserWizard.CreateTableCell();
     cell2.Controls.Add(container.PasswordHintLabel);
     row.Cells.Add(cell2);
     this._wizard._passwordHintTableRow = row;
     table.Rows.Add(row);
 }
 private static void AddInstructionRow(Table table, CreateUserWizard.CreateUserStepContainer container)
 {
     TableRow row = CreateUserWizard.CreateDoubleSpannedColumnRow(2, new Control[] { container.InstructionLabel });
     row.PreventAutoID();
     table.Rows.Add(row);
 }
 private static void AddHelpPageLinkRow(Table table, CreateUserWizard.CreateUserStepContainer container)
 {
     TableRow row = CreateUserWizard.CreateDoubleSpannedColumnRow(new Control[] { container.HelpPageIcon, container.HelpPageLink });
     table.Rows.Add(row);
 }
 internal DefaultCreateUserContentTemplate(CreateUserWizard wizard)
 {
     this._wizard = wizard;
 }
예제 #16
0
		public static CreateUserWizard CreateTestControl (Page p)
		{
			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);

			CreateUserWizard w = new CreateUserWizard ();
			w.ID = "CreateUserWizard1";

			CreateUserWizardStep step1 = new CreateUserWizardStep ();
			CompleteWizardStep step2 = new CompleteWizardStep ();

			w.MembershipProvider = "FakeProvider";
			w.WizardSteps.Add (step1);
			w.WizardSteps.Add (step2);

			p.Form.Controls.Add (lcb);
			p.Form.Controls.Add (w);
			p.Form.Controls.Add (lce);

			//p.ClientScript.RegisterForEventValidation (w.ID);

			return w;
		}
 private void WriteFailurePanel(HtmlTextWriter writer, CreateUserWizard wizard)
 {
     string className = (wizard.ErrorMessageStyle != null) && (!String.IsNullOrEmpty(wizard.ErrorMessageStyle.CssClass)) ? wizard.ErrorMessageStyle.CssClass + " " : "";
     className += "AspNet-CreateUserWizard-FailurePanel";
     WebControlAdapterExtender.WriteBeginDiv(writer, className);
     WebControlAdapterExtender.WriteSpan(writer, "", _currentErrorText);            
     WebControlAdapterExtender.WriteEndDiv(writer);
 }
 private void AddUserNameRow(Table table, CreateUserWizard.CreateUserStepContainer container)
 {
     if (this._wizard.ConvertingToTemplate)
     {
         container.UserNameLabel.RenderAsLabel = true;
     }
     TableRow row = CreateUserWizard.CreateTwoColumnRow(container.UserNameLabel, new Control[] { container.UserNameTextBox, container.UserNameRequired });
     table.Rows.Add(row);
 }
        private void WriteEmailPanel(HtmlTextWriter writer, CreateUserWizard wizard)
        {
            TextBox textBox = wizard.FindControl("CreateUserStepContainer").FindControl("Email") as TextBox;
            if (textBox != null)
            {
                Page.ClientScript.RegisterForEventValidation(textBox.UniqueID);

                WebControlAdapterExtender.WriteBeginDiv(writer, "AspNet-CreateUserWizard-EmailPanel");
                Extender.WriteTextBox(writer, false, wizard.LabelStyle.CssClass, wizard.EmailLabelText, wizard.TextBoxStyle.CssClass, "CreateUserStepContainer_Email", "");
                WebControlAdapterExtender.WriteRequiredFieldValidator(writer, wizard.FindControl("CreateUserStepContainer").FindControl("EmailRequired") as RequiredFieldValidator, wizard.ValidatorTextStyle.CssClass, "Email", wizard.EmailRequiredErrorMessage);
                WebControlAdapterExtender.WriteEndDiv(writer);
            }
        }
 private void ConstructControls(CreateUserWizard.CreateUserStepContainer container)
 {
     string validationGroup = this._wizard.ValidationGroup;
     container.Title = CreateUserWizard.CreateLiteral();
     container.InstructionLabel = CreateUserWizard.CreateLiteral();
     container.PasswordHintLabel = CreateUserWizard.CreateLiteral();
     TextBox box = new TextBox {
         ID = "UserName"
     };
     container.UserNameTextBox = box;
     TextBox box2 = new TextBox {
         ID = "Password",
         TextMode = TextBoxMode.Password
     };
     container.PasswordTextBox = box2;
     TextBox box3 = new TextBox {
         ID = "ConfirmPassword",
         TextMode = TextBoxMode.Password
     };
     container.ConfirmPasswordTextBox = box3;
     bool enableValidation = true;
     container.UserNameRequired = CreateUserWizard.CreateRequiredFieldValidator("UserNameRequired", validationGroup, container.UserNameTextBox, enableValidation);
     container.UserNameLabel = CreateUserWizard.CreateLabelLiteral(container.UserNameTextBox);
     container.PasswordLabel = CreateUserWizard.CreateLabelLiteral(container.PasswordTextBox);
     container.ConfirmPasswordLabel = CreateUserWizard.CreateLabelLiteral(container.ConfirmPasswordTextBox);
     Image image = new Image();
     image.PreventAutoID();
     container.HelpPageIcon = image;
     HyperLink link = new HyperLink {
         ID = "HelpLink"
     };
     container.HelpPageLink = link;
     Literal literal = new Literal {
         ID = "ErrorMessage"
     };
     container.ErrorMessageLabel = literal;
     TextBox box4 = new TextBox {
         ID = "Email"
     };
     container.EmailTextBox = box4;
     container.EmailRequired = CreateUserWizard.CreateRequiredFieldValidator("EmailRequired", validationGroup, container.EmailTextBox, enableValidation);
     container.EmailLabel = CreateUserWizard.CreateLabelLiteral(container.EmailTextBox);
     RegularExpressionValidator validator = new RegularExpressionValidator {
         ID = "EmailRegExp",
         ControlToValidate = "Email",
         ErrorMessage = this._wizard.EmailRegularExpressionErrorMessage,
         ValidationExpression = this._wizard.EmailRegularExpression,
         ValidationGroup = validationGroup,
         Display = ValidatorDisplay.Dynamic,
         Enabled = enableValidation,
         Visible = enableValidation
     };
     container.EmailRegExpValidator = validator;
     container.PasswordRequired = CreateUserWizard.CreateRequiredFieldValidator("PasswordRequired", validationGroup, container.PasswordTextBox, enableValidation);
     container.ConfirmPasswordRequired = CreateUserWizard.CreateRequiredFieldValidator("ConfirmPasswordRequired", validationGroup, container.ConfirmPasswordTextBox, enableValidation);
     RegularExpressionValidator validator2 = new RegularExpressionValidator {
         ID = "PasswordRegExp",
         ControlToValidate = "Password",
         ErrorMessage = this._wizard.PasswordRegularExpressionErrorMessage,
         ValidationExpression = this._wizard.PasswordRegularExpression,
         ValidationGroup = validationGroup,
         Display = ValidatorDisplay.Dynamic,
         Enabled = enableValidation,
         Visible = enableValidation
     };
     container.PasswordRegExpValidator = validator2;
     CompareValidator validator3 = new CompareValidator {
         ID = "PasswordCompare",
         ControlToValidate = "ConfirmPassword",
         ControlToCompare = "Password",
         Operator = ValidationCompareOperator.Equal,
         ErrorMessage = this._wizard.ConfirmPasswordCompareErrorMessage,
         ValidationGroup = validationGroup,
         Display = ValidatorDisplay.Dynamic,
         Enabled = enableValidation,
         Visible = enableValidation
     };
     container.PasswordCompareValidator = validator3;
     TextBox box5 = new TextBox {
         ID = "Question"
     };
     container.QuestionTextBox = box5;
     TextBox box6 = new TextBox {
         ID = "Answer"
     };
     container.AnswerTextBox = box6;
     container.QuestionRequired = CreateUserWizard.CreateRequiredFieldValidator("QuestionRequired", validationGroup, container.QuestionTextBox, enableValidation);
     container.AnswerRequired = CreateUserWizard.CreateRequiredFieldValidator("AnswerRequired", validationGroup, container.AnswerTextBox, enableValidation);
     container.QuestionLabel = CreateUserWizard.CreateLabelLiteral(container.QuestionTextBox);
     container.AnswerLabel = CreateUserWizard.CreateLabelLiteral(container.AnswerTextBox);
 }
 private void WriteFinalValidators(HtmlTextWriter writer, CreateUserWizard wizard)
 {
     WebControlAdapterExtender.WriteBeginDiv(writer, "AspNet-CreateUserWizard-FinalValidatorsPanel");
     WebControlAdapterExtender.WriteCompareValidator(writer, wizard.FindControl("CreateUserStepContainer").FindControl("PasswordCompare") as CompareValidator, wizard.ValidatorTextStyle.CssClass, "ConfirmPassword", wizard.ConfirmPasswordCompareErrorMessage, "Password");
     WebControlAdapterExtender.WriteRegularExpressionValidator(writer, wizard.FindControl("CreateUserStepContainer").FindControl("PasswordRegExpValidator") as RegularExpressionValidator, wizard.ValidatorTextStyle.CssClass, "Password", wizard.PasswordRegularExpressionErrorMessage, wizard.PasswordRegularExpression);
     WebControlAdapterExtender.WriteRegularExpressionValidator(writer, wizard.FindControl("CreateUserStepContainer").FindControl("EmailRegExpValidator") as RegularExpressionValidator, wizard.ValidatorTextStyle.CssClass, "Email", wizard.EmailRegularExpressionErrorMessage, wizard.EmailRegularExpression);
     WebControlAdapterExtender.WriteEndDiv(writer);
 }
 private void LayoutControls(CreateUserWizard.CreateUserStepContainer container)
 {
     Table table = CreateUserWizard.CreateTable();
     table.EnableViewState = false;
     AddTitleRow(table, container);
     AddInstructionRow(table, container);
     this.AddUserNameRow(table, container);
     this.AddPasswordRow(table, container);
     this.AddPasswordHintRow(table, container);
     this.AddConfirmPasswordRow(table, container);
     this.AddEmailRow(table, container);
     this.AddQuestionRow(table, container);
     this.AddAnswerRow(table, container);
     this.AddPasswordCompareValidatorRow(table, container);
     this.AddPasswordRegexValidatorRow(table, container);
     this.AddEmailRegexValidatorRow(table, container);
     AddErrorMessageRow(table, container);
     AddHelpPageLinkRow(table, container);
     container.AddChildControl(table);
 }
        /////////////////////////////////////////////////////////
        // Complete step
        /////////////////////////////////////////////////////////

        private void WriteSuccessTextPanel(HtmlTextWriter writer, CreateUserWizard wizard)
        {
            if (!String.IsNullOrEmpty(wizard.CompleteSuccessText))
            {
                string className = (wizard.CompleteSuccessTextStyle != null) && (!String.IsNullOrEmpty(wizard.CompleteSuccessTextStyle.CssClass)) ? wizard.CompleteSuccessTextStyle.CssClass + " " : "";
                className += "AspNet-CreateUserWizard-SuccessTextPanel";
                WebControlAdapterExtender.WriteBeginDiv(writer, className);
                WebControlAdapterExtender.WriteSpan(writer, "", wizard.CompleteSuccessText);
                WebControlAdapterExtender.WriteEndDiv(writer);
            }
        }
 internal DefaultCreateUserNavigationTemplate(CreateUserWizard wizard)
 {
     this._wizard = wizard;
 }
 private void WriteEditProfilePanel(HtmlTextWriter writer, CreateUserWizard wizard)
 {
     if ((!String.IsNullOrEmpty(wizard.EditProfileUrl)) || (!String.IsNullOrEmpty(wizard.EditProfileText)))
     {
         WebControlAdapterExtender.WriteBeginDiv(writer, "AspNet-CreateUserWizard-EditProfilePanel");
         WebControlAdapterExtender.WriteImage(writer, wizard.EditProfileIconUrl, "Edit profile");
         WebControlAdapterExtender.WriteLink(writer, wizard.HyperLinkStyle.CssClass, wizard.EditProfileUrl, "EditProfile", wizard.EditProfileText);
         WebControlAdapterExtender.WriteEndDiv(writer);
     }
 }
 public LayoutTemplateWizardRendering(CreateUserWizard owner) : base(owner)
 {
     this.Owner = owner;
 }
			public CreateUserStepNavigationTemplate (CreateUserWizard createUserWizard) {
				_createUserWizard = createUserWizard;
			}
 public TableWizardRendering(CreateUserWizard wizard) : base(wizard)
 {
     this.Owner = wizard;
 }
			public CompleteStepTemplate (CreateUserWizard createUserWizard)
			{
				_createUserWizard = createUserWizard;
			}
 private void WriteStepTitlePanel(HtmlTextWriter writer, CreateUserWizard wizard)
 {
     if (!String.IsNullOrEmpty(wizard.ActiveStep.Title))
     {
         string className = (wizard.TitleTextStyle != null) && (!String.IsNullOrEmpty(wizard.TitleTextStyle.CssClass)) ? wizard.TitleTextStyle.CssClass + " " : "";
         className += "AspNet-CreateUserWizard-StepTitlePanel";
         WebControlAdapterExtender.WriteBeginDiv(writer, className, "");
         WebControlAdapterExtender.WriteSpan(writer, "", wizard.ActiveStep.Title);
         WebControlAdapterExtender.WriteEndDiv(writer);
     }
 }