feat: creation de l'entité USER de façon sécurisée (cf mon cours) + installation de Tailwind sur le projet + première ébauche d'une page de connexion

This commit is contained in:
2026-03-16 10:03:57 +01:00
parent 1454b9bfc8
commit 38b1293a27
30 changed files with 8159 additions and 263 deletions

268
src/Entity/User.php Normal file
View File

@@ -0,0 +1,268 @@
<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\Table(name: '`user`')]
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_EMAIL', fields: ['email'])]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
#[ORM\Column(type: 'uuid', unique: true)]
private ?Uuid $id;
#[ORM\Column(length: 180, unique: true)]
private ?string $email = null;
/**
* @var list<string> The user roles
*/
#[ORM\Column]
private array $roles = [];
/**
* @var ?string The hashed password
*/
#[ORM\Column]
private ?string $password = null;
#[ORM\Column(length: 255)]
private ?string $emailQuota = null;
#[ORM\Column(length: 255)]
private ?string $emailDeSecours = null;
#[ORM\Column(length: 255)]
private ?string $identifiantKaz = null;
#[ORM\Column(length: 255)]
private ?string $quota = null;
#[ORM\Column]
private ?bool $hasNextcloudAccess = null;
#[ORM\Column(length: 255)]
private ?string $nextcloudQuota = null;
#[ORM\Column]
private ?bool $hasMobilizon = null;
#[ORM\Column]
private ?bool $hasAgoraAccess = null;
#[ORM\Column(length: 255)]
private ?string $lastname = null;
#[ORM\Column(length: 255)]
private ?string $firstname = null;
public function getId(): ?Uuid
{
return $this->id;
}
public function setId(Uuid $id): static
{
$this->id = $id;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): static
{
$this->email = $email;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->email;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
/**
* @param list<string> $roles
*/
public function setRoles(array $roles): static
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password): static
{
$this->password = $password;
return $this;
}
/**
* Ensure the session doesn't contain actual password hashes by CRC32C-hashing them, as supported since Symfony 7.3.
*/
public function __serialize(): array
{
$data = (array) $this;
$data["\0".self::class."\0password"] = hash('crc32c', $this->password);
return $data;
}
public function getEmailQuota(): ?string
{
return $this->emailQuota;
}
public function setEmailQuota(string $emailQuota): static
{
$this->emailQuota = $emailQuota;
return $this;
}
public function getEmailDeSecours(): ?string
{
return $this->emailDeSecours;
}
public function setEmailDeSecours(string $emailDeSecours): static
{
$this->emailDeSecours = $emailDeSecours;
return $this;
}
public function getIdentifiantKaz(): ?string
{
return $this->identifiantKaz;
}
public function setIdentifiantKaz(string $identifiantKaz): static
{
$this->identifiantKaz = $identifiantKaz;
return $this;
}
public function getQuota(): ?string
{
return $this->quota;
}
public function setQuota(string $quota): static
{
$this->quota = $quota;
return $this;
}
public function hasNextcloudAccess(): ?bool
{
return $this->hasNextcloudAccess;
}
public function setHasNextcloudAccess(bool $hasNextcloudAccess): static
{
$this->hasNextcloudAccess = $hasNextcloudAccess;
return $this;
}
public function getNextcloudQuota(): ?string
{
return $this->nextcloudQuota;
}
public function setNextcloudQuota(string $nextcloudQuota): static
{
$this->nextcloudQuota = $nextcloudQuota;
return $this;
}
public function hasMobilizon(): ?bool
{
return $this->hasMobilizon;
}
public function setHasMobilizon(bool $hasMobilizon): static
{
$this->hasMobilizon = $hasMobilizon;
return $this;
}
public function hasAgoraAccess(): ?bool
{
return $this->hasAgoraAccess;
}
public function setHasAgoraAccess(bool $hasAgoraAccess): static
{
$this->hasAgoraAccess = $hasAgoraAccess;
return $this;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(string $lastname): static
{
$this->lastname = $lastname;
return $this;
}
public function getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(string $firstname): static
{
$this->firstname = $firstname;
return $this;
}
}