public void ChangePassword_Click(object sender, EventArgs e) { using (LoginService service = new LoginService()) { try { if (!NewPassword.Text.Equals(ConfirmNewPassword.Text) || NewPassword.Text.Equals(string.Empty)) { ErrorMessage.Text = ErrorMessages.PasswordsDontMatch; ErrorMessagePanel.Visible = true; } else { service.ChangePassword(Username.Text, OriginalPassword.Value, NewPassword.Text); SessionManager.InitializeSession(Username.Text, NewPassword.Text); } } catch (Exception ex) { ErrorMessage.Text = ex.Message; ErrorMessagePanel.Visible = true; NewPassword.Focus(); // May want to elimiate this. Platform.Log(LogLevel.Error, ex, "Unexpected exception changing password: {0}.", ex.Message); } } }
public void Show(string username, string password) { Username.Text = username; OriginalPassword.Value = password; ErrorMessagePanel.Visible = false; Panel1.DefaultButton = "OKButton"; NewPassword.Focus(); ModalDialog1.Show(); }
protected void Page_Load(object sender, EventArgs e) { if (ConfigurationManager.AppSettings["GlbUserId"] == "") { Response.Redirect("UnAuthorized.aspx"); } OldPassword.Text = "Nesimi123456789"; NewPassword.Focus(); }
protected void Page_Load(object sender, EventArgs e) { if (this.RequiresOldPassword) { OldPassword.Focus(); } else { NewPassword.Focus(); } }
protected void ChangePasswordPushButton_Click(object sender, EventArgs e) { errorLink.Visible = true; if (handleTokenCheck(false) && ConfirmNewPassword.Text == NewPassword.Text && ConfirmNewPassword.Text.Length >= 6) { MembershipUser mu = Membership.GetUser(Context.Request.QueryString["email"].Trim(), false); if (mu != null) { if (!mu.IsLockedOut) { string temp = mu.ResetPassword(); if (mu.ChangePassword(temp, NewPassword.Text)) { corruptedText.Text = "Your password has been changed. You may now log in."; Session.Add("change", corruptedText.Text); deleteUserTokens(); Response.Redirect("/Public/Login.aspx?ReturnUrl=%2fDefault.aspx"); } else { corruptedText.Text = "Error. Your password has not been changed. Please contact the site administrator."; } } else { corruptedText.Text = "Your account has been locked. Please contact the site administrator."; } } else { corruptedText.Text = "Invalid Username. Try again."; } } else { corruptedText.Text = "There was an error changing your password. Please make " + "sure they match and are both at least 6 characters long. Contact us if you continue to have difficulty."; NewPassword.Focus(); changeForm.Visible = true; initialEmail.Visible = false; } }
public UpdatePasswordPage() { InitializeComponent(); this.BindingContext = new ViewModel.UpdatePasswordViewModel(); Password.Completed += (s, e) => NewPassword.Focus(); NewPassword.Completed += (s, e) => ConfirmPassword.Focus(); ConfirmPassword.Completed += (s, e) => { var current = this.BindingContext as ViewModel.UpdatePasswordViewModel; current.UpdateCommand.Execute(null); Password.Focus(); }; }
private void NewUsername_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { if (NewUsername.Text == "") { MessageBox.Show("Введите логин!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } else if (NewPassword.Password == "") { NewPassword.Focus(); } else { SignIn(); } } }
protected bool handleTokenCheck(bool handleChangeForm = true) { if (Context.Request.QueryString["email"] != null && Context.Request.QueryString["t"] != null) { tokenMaker = new TokenValidator(Context.Request.QueryString["email"], Context.Request.QueryString["t"]); if (tokenMaker.ValidateUserToken()) { NewPassword.Focus(); changeForm.Visible = handleChangeForm; return(true); } else { errorLink.Visible = true; } } return(false); }
private void button1_Click(object sender, RoutedEventArgs e) { string strUsername = UserName.Text; string strPassword = Password.Password; string strPassword2 = NewPassword.Password; string strPassword3 = ConfirmPassword.Password; string regex = "[A-Za-z0-9]{6,16}"; if (string.IsNullOrEmpty(strUsername)) { MessageBox.Show("请输入用户名!"); UserName.Focus(); return; } else if (string.IsNullOrEmpty(strPassword)) { MessageBox.Show("请输入密码!"); Password.Focus(); return; } else if (!strPassword2.Equals(strPassword3)) { MessageBox.Show("两次密码不一致!,请重输。"); NewPassword.Focus(); return; } else if (!Regex.IsMatch(strPassword, regex)) { MessageBox.Show("请输入规范的密码,密码长度6-20位。"); Password.Focus(); return; } else { MessageBox.Show("恭喜您修改成功!" + '\n' + "您的信息如下:" + '\n' + strUsername + '\n' + strGender + '\n' + strPassword2); this.Close(); } }
private bool IsValidate() { if (NewPassword.Text.Trim() == string.Empty) { MessageBox.Show("New Password is Required.", "error", MessageBoxButtons.OK, MessageBoxIcon.Error); NewPassword.Focus(); return(false); } if (ConfirmPassword.Text.Trim() == string.Empty) { MessageBox.Show("confirm Password is Required.", "error", MessageBoxButtons.OK, MessageBoxIcon.Error); ConfirmPassword.Focus(); return(false); } if (NewPassword.Text.Trim() != ConfirmPassword.Text.Trim()) { MessageBox.Show("Confirm Password doesn't match.", "error", MessageBoxButtons.OK, MessageBoxIcon.Error); ConfirmPassword.Focus(); return(false); } return(true); }
public EditPassword() { InitializeComponent(); password = rep.GetPass; SaveBt.MouseDown += GlobalVars.mMouseDown; CancelBt.MouseDown += GlobalVars.mMouseDown; SaveBt.MouseUp += GlobalVars.mMouseUp; CancelBt.MouseUp += GlobalVars.mMouseUp; SaveBt.MouseLeave += GlobalVars.mMouseLeave; CancelBt.MouseLeave += GlobalVars.mMouseLeave; //BadName.Visibility = Visibility.Hidden; //BadSurname.Visibility = Visibility.Hidden; //BadSecondName.Visibility = Visibility.Hidden; BadLabel.Visibility = Visibility.Hidden; NewPassword.PreviewKeyDown += (sender, e) => { if (e.Key == Key.Enter) { SaveNewPassword(); } }; ConfirmPassword.PreviewKeyDown += (sender, e) => { if (e.Key == Key.Enter) { SaveNewPassword(); } }; NewPassword.PasswordChanged += (sender, e) => { if (!BadNewPassword.BorderBrush.Equals(Brushes.LightGray)) { BadNewPassword.BorderBrush = Brushes.LightGray; if (BadConfirmPassword.BorderBrush.Equals(Brushes.LightGray)) { BadLabel.Visibility = Visibility.Hidden; } } if (BadLabel.Visibility.Equals(Visibility.Visible) && BadConfirmPassword.BorderBrush.Equals(Brushes.LightGray)) { BadLabel.Visibility = Visibility.Hidden; } }; ConfirmPassword.PasswordChanged += (sender, e) => { if (!BadConfirmPassword.BorderBrush.Equals(Brushes.LightGray)) { BadConfirmPassword.BorderBrush = Brushes.LightGray; if (BadNewPassword.BorderBrush.Equals(Brushes.LightGray)) { BadLabel.Visibility = Visibility.Hidden; } } if (BadLabel.Visibility.Equals(Visibility.Visible) && BadNewPassword.BorderBrush.Equals(Brushes.LightGray)) { BadLabel.Visibility = Visibility.Hidden; } }; NewPassword.IsEnabled = false; ConfirmPassword.IsEnabled = false; Password.PasswordChanged += (sender, e) => { if (GlobalVars.GetHashCode(Password.Password) == password) { Password.IsEnabled = false; NewPassword.IsEnabled = true; ConfirmPassword.IsEnabled = true; NewPassword.Focus(); } }; CancelBt.MouseUp += (sender, e) => { if (!GlobalVars.IsPressedFlag) { return; } GlobalVars.IsPressedFlag = false; this.Close(); }; SaveBt.MouseUp += (sender, e) => { if (!GlobalVars.IsPressedFlag) { return; } GlobalVars.IsPressedFlag = false; SaveNewPassword(); }; Password.Focus(); }
private async void SaveNewPassword() { SaveLabel.Focusable = true; SaveLabel.Focus(); SaveLabel.Focusable = false; if (Password.IsEnabled) { this.Close(); } var flag = true; if (NewPassword.Password.Equals(string.Empty)) { flag = false; BadNewPassword.BorderBrush = Brushes.Red; } if (ConfirmPassword.Password.Equals(string.Empty)) { flag = false; BadConfirmPassword.BorderBrush = Brushes.Red; } if (!flag) { BadLabel.Content = "Заполните обязательные поля"; BadLabel.Visibility = Visibility.Visible; return; } if (NewPassword.Password != ConfirmPassword.Password) { NewPassword.Clear(); ConfirmPassword.Clear(); NewPassword.Focus(); BadLabel.Content = "Пароли не совпадают"; BadLabel.Visibility = Visibility.Visible; return; } if (NewPassword.Password == Password.Password) { NewPassword.Clear(); ConfirmPassword.Clear(); NewPassword.Focus(); BadLabel.Content = "Пароль уже используется"; BadLabel.Visibility = Visibility.Visible; return; } //rep.EditPass(NewPassword.Password); rep.GetPass = GlobalVars.GetHashCode(NewPassword.Password); // EncDecHelper.SetPassword(NewPassword.Password); await this.ShowMessageAsync(string.Empty, "Password has changed."); this.Close(); }
private void OldPassword_Completed(object sender, EventArgs e) { NewPassword.Focus(); }
private void Button1_Click(System.Object sender, System.EventArgs e) { try { int RowsAffected = 0; if (Strings.Len(Strings.Trim(cmbUserType.Text)) == 0) { MessageBox.Show("Please select user type", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); cmbUserType.Focus(); return; } if (Strings.Len(Strings.Trim(UserName.Text)) == 0) { MessageBox.Show("Please enter user name", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); UserName.Focus(); return; } if (Strings.Len(Strings.Trim(OldPassword.Text)) == 0) { MessageBox.Show("Please enter old password", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); OldPassword.Focus(); return; } if (Strings.Len(Strings.Trim(NewPassword.Text)) == 0) { MessageBox.Show("Please enter new password", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); NewPassword.Focus(); return; } if (Strings.Len(Strings.Trim(ConfirmPassword.Text)) == 0) { MessageBox.Show("Please confirm new password", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); ConfirmPassword.Focus(); return; } if (NewPassword.TextLength < 5) { MessageBox.Show("The New Password Should be of Atleast 5 Characters", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); NewPassword.Text = ""; ConfirmPassword.Text = ""; NewPassword.Focus(); return; } else if (NewPassword.Text != ConfirmPassword.Text) { MessageBox.Show("Password do not match", "Input error", MessageBoxButtons.OK, MessageBoxIcon.Error); NewPassword.Text = ""; OldPassword.Text = ""; ConfirmPassword.Text = ""; OldPassword.Focus(); return; } else if (OldPassword.Text == NewPassword.Text) { MessageBox.Show("Password is same..Re-enter new password", "Input error", MessageBoxButtons.OK, MessageBoxIcon.Error); NewPassword.Text = ""; ConfirmPassword.Text = ""; NewPassword.Focus(); return; } con = new OleDbConnection(ck); con.Open(); string co = "update Registration set user_password = '******'where username='******' and user_password = '******' and usertype='" + cmbUserType.Text + "'"; cmd = new OleDbCommand(co); cmd.Connection = con; RowsAffected = cmd.ExecuteNonQuery(); if (RowsAffected > 0) { MessageBox.Show("Successfully changed", "Password", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); My.MyProject.Forms.Frmlogin.Show(); My.MyProject.Forms.Frmlogin.cmbUserType.Text = ""; My.MyProject.Forms.Frmlogin.txtUsername.Text = ""; My.MyProject.Forms.Frmlogin.txtPassword.Text = ""; My.MyProject.Forms.Frmlogin.cmbUserType.Focus(); } else { MessageBox.Show("invalid user name or password", "input error", MessageBoxButtons.OK, MessageBoxIcon.Error); UserName.Text = ""; NewPassword.Text = ""; OldPassword.Text = ""; ConfirmPassword.Text = ""; UserName.Focus(); } con.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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."; } } }
async void SavePasswordClicked(object sender, EventArgs args) { if (string.IsNullOrEmpty(CurrentPassword.Text)) { await dialogService.ShowMessage("Error", "You must enter the current password."); CurrentPassword.Focus(); return; } if (string.IsNullOrEmpty(NewPassword.Text)) { await dialogService.ShowMessage("Error", "You must enter the new password."); NewPassword.Focus(); return; } if (string.IsNullOrEmpty(ConfirmPassword.Text)) { await dialogService.ShowMessage("Error", "You must enter the confirm password."); ConfirmPassword.Focus(); return; } if (!employee.Password.Equals(CurrentPassword.Text)) { await dialogService.ShowMessage("Error", "Current passwword incorrect"); CurrentPassword.Focus(); return; } if (!NewPassword.Text.Equals(ConfirmPassword.Text)) { await dialogService.ShowMessage("Error", "New password and confirm password must be equals"); NewPassword.Focus(); return; } var checkConnetion = await apiService.CheckConnection(); if (!checkConnetion.IsSuccess) { await dialogService.ShowMessage("Error", checkConnetion.Message); return; } var urlAPI = Application.Current.Resources["URLAPI"].ToString(); var changePassword = new ChangePasswordRequest { Email = employee.Email, CurrentPassword = CurrentPassword.Text, NewPassword = NewPassword.Text, }; var response = await apiService.PostPassword <ChangePasswordRequest>( urlAPI, "/api", "/Employees/ChangePassword", employee.TokenType, employee.AccessToken, changePassword); if (!response.IsSuccess) { await dialogService.ShowMessage("Error", response.Message); return; } mainViewModel.Employee.Password = changePassword.NewPassword; dataService.DeleteAllAndInsert(mainViewModel.Employee); await dialogService.ShowMessage("Accept", "Password has been successfully"); PasswordModal.IsVisible = false; }