passwordPolicy->assert($command->newPassword); $usedAt = date('Y-m-d H:i:s'); $newHash = $this->passwordPolicy->hash($command->newPassword); $this->transactionManager->run(function () use ($command, $usedAt, $newHash): void { $row = $this->passwordResetRepository->consumeActiveToken(hash('sha256', $command->tokenRaw), $usedAt); if ($row === null) { throw new InvalidResetTokenException(); } $user = $this->userRepository->findById((int) $row['user_id']); if ($user === null) { throw new InvalidResetTokenException(); } $this->userRepository->updatePassword($user->getId(), $newHash); }); } }