private async void btnChangePass_Click(object sender, EventArgs e) { if (txtNewPass.Text != txtNewPassConfirmation.Text) { MessageBox.Show("New passwords do not match", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } KorisnikChangePass request = new KorisnikChangePass { KorisnickoIme = txtUserNAme.Text, NoviPass = txtNewPass.Text, pass = txtOldPass.Text }; bool x = await _servicePass.ChangePass <bool>(request); if (x == false) { MessageBox.Show("Old Password Incorrect", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } MessageBox.Show("Password succesfully changed !\n Please log in.", "Succes", MessageBoxButtons.OK, MessageBoxIcon.Information); Form hehe = FindForm(); hehe.Dispose(); hehe.Close(); frmLogin frmLogin = new frmLogin(); frmLogin.ShowDialog(); }
public bool ChangePass(KorisnikChangePass request) { var u = _context.Korisniks.FirstOrDefault(x => x.KorisnickoIme == request.KorisnickoIme); var newHash = GenerateHash(u.LozinkaSalt, request.pass); if (newHash == u.LozinkaHash) { u.LozinkaSalt = GenerateSalt(); u.LozinkaHash = GenerateHash(u.LozinkaSalt, request.NoviPass); var entity = _context.Korisniks.Find(u.KorisnikId); _context.Korisniks.Attach(u); _context.Korisniks.Update(u); _context.SaveChanges(); return(true); } return(false); }
public bool ChangePass([FromBody] KorisnikChangePass request) { return(_service.ChangePass(request)); }