[#321] Gestion des rôles dans l'application (#2)
All checks were successful
Auto Tag Develop / tag (push) Successful in 6s

| Numéro du ticket | Titre du ticket |
|------------------|-----------------|
|        #321          |        Gestion des rôles dans l'application         |

## Description de la PR
[#321] Gestion des rôles dans l'application

## Modification du .env

## Check list

- [x] Pas de régression
- [ ] TU/TI/TF rédigée
- [x] TU/TI/TF OK
- [ ] CHANGELOG modifié

Reviewed-on: #2
Co-authored-by: tristan <tristan@yuno.malio.fr>
Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #2.
This commit is contained in:
2026-02-16 07:19:05 +00:00
committed by Autin
parent 4845230429
commit 76f1363457
19 changed files with 965 additions and 40 deletions

View File

@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace App\State;
use ApiPlatform\Doctrine\Common\State\PersistProcessor;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProcessorInterface;
use App\Entity\User;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
final readonly class UserPasswordHasherProcessor implements ProcessorInterface
{
public function __construct(
private PersistProcessor $persistProcessor,
private UserPasswordHasherInterface $passwordHasher
) {}
public function process(
mixed $data,
Operation $operation,
array $uriVariables = [],
array $context = []
): mixed {
if ($data instanceof User && '' !== $data->getPlainPassword()) {
$hashed = $this->passwordHasher->hashPassword($data, $data->getPlainPassword());
$data->setPassword($hashed);
$data->setPlainPassword('');
}
return $this->persistProcessor->process($data, $operation, $uriVariables, $context);
}
}