31 lines
843 B
PHP
31 lines
843 B
PHP
<?php
|
|
|
|
namespace App\Controller;
|
|
|
|
use App\Dto\Input\UserInput;
|
|
use App\Entity\User;
|
|
use App\Handler\ResetPasswordHandler;
|
|
use App\Repository\UserRepository;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\HttpKernel\Attribute\AsController;
|
|
|
|
#[AsController]
|
|
class ResetPasswordAction extends AbstractController
|
|
{
|
|
public function __construct(
|
|
private readonly ResetPasswordHandler $resetPasswordHandler,
|
|
private readonly UserRepository $userRepository
|
|
)
|
|
{
|
|
|
|
}
|
|
|
|
public function __invoke(string $uuid, UserInput $input): UserInput
|
|
{
|
|
/** @var User $user */
|
|
$user = $this->userRepository->findOneByUuid($uuid);
|
|
$this->resetPasswordHandler->handle($user, $input->currentPassword, $input->newPassword);
|
|
|
|
return new UserInput($user);
|
|
}
|
|
} |