public override string Validate(string propertyName) { if (!DoValidation) { return(null); } switch (propertyName) { case nameof(NewPassword): if (NewPassword.IsNullOrWhiteSpace()) { return(string.Format(Constants.FieldMustBeFilledMessageFormat, nameof(NewPassword))); } else if (!NewPassword.IsLengthBetween(5, 32)) { return(string.Format(Constants.LengthErrorMessageFormat, nameof(NewPassword), 5, 32)); } break; case nameof(ConfirmNewPassword): if (ConfirmNewPassword.IsNullOrWhiteSpace()) { return(string.Format(Constants.FieldMustBeFilledMessageFormat, nameof(ConfirmNewPassword))); } else if (!ConfirmNewPassword.IsLengthBetween(5, 32)) { return(string.Format(Constants.LengthErrorMessageFormat, nameof(ConfirmNewPassword), 5, 32)); } break; } return(null); }
private bool hasErrors() { if (NewPassword.Value.Equals(Password.Value)) { NewPassword.Error = "must enter a new password"; } if (NewPassword.Value.Equals(ConfirmNewPassword.Value)) { ConfirmNewPassword.Error = "password must match"; } return(Password.hasErrors() || NewPassword.hasErrors() || ConfirmNewPassword.hasErrors()); }
public async Task <Boolean> ResetPassword(ConfirmNewPassword confirmNewPassword) { try { var response = await _httpClientService.SendHttpPostRequest(confirmNewPassword, "users/ResetPassword/"); return(response.Equals("true")); } catch { return(false); } }
public async Task <IActionResult> ResetPasswordConfirmation(ConfirmNewPassword confirmNewPassword) { if (!ModelState.IsValid) { return(View("ResetPassword", confirmNewPassword)); } var passwordChanged = await _accountService.ResetPassword(confirmNewPassword); if (passwordChanged) { ViewBag.passwordChanged = true; return(View("ResetPassword")); } else { ViewBag.passwordChanged = false; return(View("ResetPassword", confirmNewPassword)); } }
public void EnterDetails(Table table) { foreach (var row in table.Rows) { switch (row[0].ToLower()) { case "currentpassword": CurrentPassword.SendKeys(row[1]); break; case "newpassword": NewPassword.SendKeys(row[1]); break; case "confirmnewpassword": ConfirmNewPassword.SendKeys(row[1]); break; default: throw new Exception(string.Format("Field {0} not defined", row[0])); } } }
private void Save(object sender, RoutedEventArgs e) { if (ShowPasswordCharsCheckBox.IsChecked == true) { PasswordText.Text = Password.Password; NewPasswordText.Text = NewPassword.Password; ConfirmNewPasswordText.Text = ConfirmNewPassword.Password; } string username = Username.Text; string email = Email.Text; string password = Password.Password; string newpassword = NewPassword.Password; string confirmnewpassword = ConfirmNewPassword.Password; string dateofbirth = DateOfBirth.Text; string preferredlocation = PreferredLocation.Text; string preferredlanguage = PreferredLanguage.Text; if (ChangePasswordCharsCheckBox.IsChecked == false) { //ErrorMessage.Visibility = Visibility.Visible; //ErrorMessage.Background = Brushes.Green; //ErrorMessage.Text = "Updating your Profile..."; SqlConnection con = new SqlConnection("Data Source = BMWP2; Initial Catalog = M120_Database; Integrated Security = True"); con.Open(); SqlCommand cmd = new SqlCommand("UPDATE Users (Username,Email,DateOfBirth,PreferredLocation,PreferredLanguage) SET Username='******',Email='" + email + "',DateOfBirth='" + dateofbirth + "',PreferredLocation='" + preferredlocation + "',PreferredLanguage='" + preferredlanguage + "'", con); cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); con.Close(); //ErrorMessage.Text = "Profile Update successful."; } else { if (NewPassword.Password.Length == 0) { //ErrorMessage.Visibility = Visibility.Visible; //ErrorMessage.Background = Brushes.Yellow; //ErrorMessage.Text = "Enter password!"; NewPassword.Focus(); } else if (ConfirmNewPassword.Password.Length == 0) { //ErrorMessage.Visibility = Visibility.Visible; //ErrorMessage.Background = Brushes.Yellow; //ErrorMessage.Text = "Enter Confirm password!"; ConfirmNewPassword.Focus(); } else if (NewPassword.Password != ConfirmNewPassword.Password) { //ErrorMessage.Visibility = Visibility.Visible; //ErrorMessage.Background = Brushes.Yellow; //ErrorMessage.Text = "Confirm password must be same as password!"; ConfirmNewPassword.Focus(); } else { //ErrorMessage.Visibility = Visibility.Visible; //ErrorMessage.Background = Brushes.Green; //ErrorMessage.Text = "Updating your Profile..."; SqlConnection con = new SqlConnection("Data Source = BMWP2; Initial Catalog = M120_Database; Integrated Security = True"); con.Open(); SqlCommand cmd = new SqlCommand("UPDATE Users (Username,Email,Password,DateOfBirth,PreferredLocation,PreferredLanguage) SET Username='******',Email='" + email + "',Password='******',DateOfBirth='" + dateofbirth + "',PreferredLocation='" + preferredlocation + "',PreferredLanguage='" + preferredlanguage + "'", con); cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); con.Close(); //ErrorMessage.Text = "Profile Update successful."; } } }