2026-04-09 20:21:01 +02:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
|
/*
|
|
|
|
|
* This file is part of the SplendidBear Websites' projects.
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2026 @ www.splendidbear.org
|
|
|
|
|
*
|
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace App\Entity;
|
|
|
|
|
|
|
|
|
|
use App\Repository\UserRepository;
|
2026-04-12 08:10:36 +02:00
|
|
|
use DateTime;
|
|
|
|
|
use Doctrine\DBAL\Types\Types;
|
2026-04-09 20:21:01 +02:00
|
|
|
use Doctrine\ORM\Mapping\Column;
|
|
|
|
|
use Doctrine\ORM\Mapping\Entity;
|
|
|
|
|
use Doctrine\ORM\Mapping\GeneratedValue;
|
|
|
|
|
use Doctrine\ORM\Mapping\Id;
|
2026-04-11 20:45:51 +02:00
|
|
|
use Doctrine\ORM\Mapping\Table;
|
2026-04-09 20:21:01 +02:00
|
|
|
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
|
|
|
|
use Symfony\Component\Security\Core\User\UserInterface;
|
2026-04-11 20:45:51 +02:00
|
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
2026-04-09 20:21:01 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class User
|
|
|
|
|
*
|
|
|
|
|
* @package App\Entity
|
|
|
|
|
* @author Lang <https://www.splendidbear.org>
|
|
|
|
|
* @category Class
|
|
|
|
|
* @license https://www.gnu.org/licenses/lgpl-3.0.en.html GNU Lesser General Public License
|
|
|
|
|
* @link www.splendidbear.org
|
|
|
|
|
* @since 2026. 04. 09.
|
|
|
|
|
*/
|
2026-04-11 20:45:51 +02:00
|
|
|
#[Table(name: 'app_user')]
|
2026-04-09 20:21:01 +02:00
|
|
|
#[Entity(repositoryClass: UserRepository::class)]
|
|
|
|
|
class User implements UserInterface, PasswordAuthenticatedUserInterface
|
|
|
|
|
{
|
|
|
|
|
#[Id, GeneratedValue, Column]
|
|
|
|
|
private ?int $id = null;
|
|
|
|
|
|
|
|
|
|
#[Column(length: 180, unique: true)]
|
|
|
|
|
private ?string $username = null;
|
|
|
|
|
|
|
|
|
|
#[Column]
|
|
|
|
|
private array $roles = [];
|
|
|
|
|
|
|
|
|
|
#[Column(nullable: true)]
|
|
|
|
|
private ?string $password = null;
|
|
|
|
|
|
2026-04-11 20:45:51 +02:00
|
|
|
#[Column(length: 254, unique: true, nullable: true)]
|
|
|
|
|
private ?string $email = null;
|
|
|
|
|
|
|
|
|
|
#[Column]
|
|
|
|
|
private bool $isVerified = false;
|
|
|
|
|
|
|
|
|
|
#[Column(length: 64, nullable: true)]
|
|
|
|
|
private ?string $verificationToken = null;
|
|
|
|
|
|
2026-04-12 08:10:36 +02:00
|
|
|
#[Column(length: 64, nullable: true)]
|
|
|
|
|
private ?string $resetToken = null;
|
|
|
|
|
|
|
|
|
|
#[Column(type: Types::DATETIME_MUTABLE, nullable: true)]
|
|
|
|
|
private ?DateTime $resetTokenExpiresAt = null;
|
|
|
|
|
|
2026-04-09 20:21:01 +02:00
|
|
|
|
|
|
|
|
public function getId(): ?int
|
|
|
|
|
{
|
|
|
|
|
return $this->id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getUsername(): ?string
|
|
|
|
|
{
|
|
|
|
|
return $this->username;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setUsername(string $username): self
|
|
|
|
|
{
|
|
|
|
|
$this->username = $username;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getUserIdentifier(): string
|
|
|
|
|
{
|
|
|
|
|
return (string) $this->username;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getRoles(): array
|
|
|
|
|
{
|
|
|
|
|
$roles = $this->roles;
|
|
|
|
|
$roles[] = 'ROLE_USER';
|
|
|
|
|
return array_unique($roles);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setRoles(array $roles): self
|
|
|
|
|
{
|
|
|
|
|
$this->roles = $roles;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getPassword(): ?string
|
|
|
|
|
{
|
|
|
|
|
return $this->password;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setPassword(?string $password): self
|
|
|
|
|
{
|
|
|
|
|
$this->password = $password;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function eraseCredentials(): void
|
|
|
|
|
{
|
|
|
|
|
}
|
2026-04-11 20:45:51 +02:00
|
|
|
|
|
|
|
|
public function getEmail(): ?string
|
|
|
|
|
{
|
|
|
|
|
return $this->email;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setEmail(?string $email): self
|
|
|
|
|
{
|
|
|
|
|
$this->email = $email;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function isVerified(): bool
|
|
|
|
|
{
|
|
|
|
|
return $this->isVerified;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setIsVerified(bool $isVerified): self
|
|
|
|
|
{
|
|
|
|
|
$this->isVerified = $isVerified;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getVerificationToken(): ?string
|
|
|
|
|
{
|
|
|
|
|
return $this->verificationToken;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setVerificationToken(?string $verificationToken): self
|
|
|
|
|
{
|
|
|
|
|
$this->verificationToken = $verificationToken;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
2026-04-12 08:10:36 +02:00
|
|
|
|
|
|
|
|
public function getResetToken(): ?string
|
|
|
|
|
{
|
|
|
|
|
return $this->resetToken;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setResetToken(?string $resetToken): self
|
|
|
|
|
{
|
|
|
|
|
$this->resetToken = $resetToken;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getResetTokenExpiresAt(): ?DateTime
|
|
|
|
|
{
|
|
|
|
|
return $this->resetTokenExpiresAt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setResetTokenExpiresAt(?DateTime $resetTokenExpiresAt): self
|
|
|
|
|
{
|
|
|
|
|
$this->resetTokenExpiresAt = $resetTokenExpiresAt;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
2026-04-09 20:21:01 +02:00
|
|
|
}
|