gestion de la connexion de l'utilisateur

This commit is contained in:
2026-03-18 17:34:21 +01:00
parent 3dcba06f20
commit d81e450a0e
19 changed files with 534 additions and 73 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Uid\Uuid;
@@ -11,6 +12,7 @@ use Symfony\Component\Uid\Uuid;
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\Table(name: '`user`')]
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_EMAIL', fields: ['email'])]
#[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
@@ -35,7 +37,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
private ?string $password = null;
#[ORM\Column(length: 255)]
private ?string $emailQuota = null;
private ?string $emailQuota = '1G';
#[ORM\Column(length: 255)]
private ?string $emailDeSecours = null;
@@ -50,7 +52,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
private ?bool $hasNextcloudAccess = null;
#[ORM\Column(length: 255)]
private ?string $nextcloudQuota = '1G';
private ?string $nextcloudQuota = null;
#[ORM\Column]
private ?bool $hasMobilizon = null;
@@ -104,9 +106,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
$roles[] = 'ROLE_USER'; // garantit qu'il a au moins ce rôle
return array_unique($roles);
}
@@ -120,6 +120,16 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
return $this;
}
/**
* @see UserInterface
* Ajout de cette fonction, car obligatoire pour faire fonctionner UserInterface correctement
*/
public function eraseCredentials(): void
{
// Si vous stockez des données temporaires sensibles sur l'utilisateur, nettoyez-les ici
// $this->plainPassword = null;
}
/**
* @see PasswordAuthenticatedUserInterface
*/