*/ #[ORM\Column(type: 'json')] private array $permissions = []; #[ORM\Column(type: 'boolean')] private bool $isActive = true; public function __construct(string $email, string $passwordHash) { $this->id = Uuid::v7(); $this->email = $email; $this->passwordHash = $passwordHash; } public function getId(): Uuid { return $this->id; } public function getEmail(): string { return $this->email; } public function getPassword(): string { return $this->passwordHash; } /** @return non-empty-string */ public function getUserIdentifier(): string { \assert('' !== $this->email); return $this->email; } /** @return list */ public function getRoles(): array { return ['ROLE_USER']; } public function eraseCredentials(): void { } public function isTotpAuthenticationEnabled(): bool { return null !== $this->totpSecret; } public function getTotpAuthenticationUsername(): string { \assert('' !== $this->email); return $this->email; } public function getTotpAuthenticationConfiguration(): ?TotpConfigurationInterface { if (null === $this->totpSecret) { return null; } return new TotpConfiguration($this->totpSecret, TotpConfiguration::ALGORITHM_SHA1, 30, 6); } public function getTotpSecret(): ?string { return $this->totpSecret; } public function setTotpSecret(?string $secret): void { $this->totpSecret = $secret; } public function isActive(): bool { return $this->isActive; } public function setPasswordHash(string $passwordHash): void { $this->passwordHash = $passwordHash; } public function setIsActive(bool $active): void { $this->isActive = $active; } /** @return array */ public function getPermissions(): array { return $this->permissions; } public function hasPermission(string $permission): bool { return $this->permissions[$permission] ?? false; } public function grantPermission(string $permission): void { $this->permissions[$permission] = true; } public function revokePermission(string $permission): void { unset($this->permissions[$permission]); } }