protected void CreateAccount(object sender, EventArgs e) { if (!cbxAgree.Checked) { lblError.Text = "You must agree to the terms and conditions!"; return; } var userManager = new UserManager(); if(txtPassword.Text != txtPasswordConfirm.Text) { lblError.Text = "Passwords Do Not Match"; return; } try { userManager.RegisterUser(txtUsername.Text, txtPassword.Text, txtEmail.Text, txtPhone.Text, txtFirstName.Text, txtLastName.Text, txtStreet1.Text, txtStreet2.Text, txtCity.Text, ddlState.SelectedValue, txtZipCode.Text, UserType.User, txtCompanyName.Text); lblError.Text = "<strong>Account Sucessfully Created! Click <a href='/Login.aspx' >here</a> To Login</strong>"; } catch(Exception ex) { lblError.Text = ex.Message; } }
protected void btnUpdate_Click(object sender, EventArgs e) { var userLogic = new UserManager(); var user = (RollingRides.WebApp.Components.Datalayer.Models.User) Session["User"]; var u2 = userLogic.ValidateLogin(user.Username, txtOldPassword.Text); var attempts = Session["attempts"] == null ? 3 : int.Parse(Session["attempts"].ToString()); if(u2 == null) { lblError.Text = "Old Password Incorrect: " + (--attempts) + " attempts remain"; Session["attemmpts"] = attempts; if(attempts == 0) { Session.Abandon(); Response.Redirect("~/login.aspx"); } return; } if(txtPassword.Text != txtConfirmPassword.Text) { lblError.Text = "New Passwords Do Not Match!"; return; } try { userLogic.ChangePassword(user.Id, txtOldPassword.Text, txtPassword.Text); lblError.Text = "Password Successfully Changed!"; } catch(Exception ex) { lblError.Text = ex.Message; } }
protected void btnSubmit_Click(object sender, EventArgs e) { try { var userLogic = new UserManager(); var newPass = userLogic.ResetPassword(txtEmail.Text); if(newPass == null) { lblMessage.Text = "This Email Address wasn't found in our system!"; return; } var emailer = EmailerFactory.NewDefaultInstance(); emailer.SendHtmlEmail(ConfigurationManager.AppSettings["FromEmail"], txtEmail.Text, "The Rolling Rides Team - Password Reset", "Hello," + "<br/>Your new password is "+newPass + "<br/>Thank you,<br/>The Rolling Rides Team"); lblMessage.Text = "Your new temporary password was emailed to your email address provided"; } catch(Exception ex) { lblMessage.Text = ex.Message; } }