public async Task <ActionResult> ResertAccountPassword(int id, [FromBody] UserResetDto userPassword) { if (id != userPassword.Id) { return(BadRequest("Melumatin gonderilmesinde xeta var")); } var user = await _context.Users.FirstOrDefaultAsync(s => s.Workers.Id == userPassword.Id); byte[] passwordHash, passwordSalt; CreatePasswordHash(userPassword.Password, out passwordHash, out passwordSalt); user.PasswordHash = passwordHash; user.PasswordSalt = passwordSalt; _context.Entry(user).State = EntityState.Modified; await _context.SaveChangesAsync(); return(Ok()); }
public JsonResult Reset([FromBody] UserResetDto dto) { var user = _loginService.ValidatePassword(dto.UserName, dto.RawPassword); if (user == null) { return(new JsonResult(new { Code = 20000, Success = false })); } else { user.Password = dto.NewPassword; _service.Update(user); return(new JsonResult(new { Code = 20000, Success = true })); } }