<?php
namespace Ksante\SsoBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Ksante\SsoBundle\Repository\UserRepository;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @ORM\Table(name="ksante_user")
*/
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
protected $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
protected $email;
/**
* @ORM\Column(type="json")
*/
protected $roles = [];
/**
* @ORM\Column(type="string", nullable=true)
*/
private $password;
/**
* @ORM\Column(name="enabled", type="boolean")
*/
protected $enabled = true;
/**
* @ORM\Column(name="connected_at", type="datetime", nullable=true)
*/
protected $connectedAt;
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = strtolower($email);
return $this;
}
/**
* @deprecated since Symfony 5.3, use getUserIdentifier instead
*/
public function getUsername(): 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);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->email;
}
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function getSalt()
{
// not needed for apps that do not check user passwords
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
}
public function isEnabled(): bool
{
return $this->enabled;
}
public function setEnabled(?bool $enabled): void
{
$this->enabled = (bool) $enabled;
}
public function getConnectedAt(): ?\DateTimeInterface
{
return $this->connectedAt;
}
public function setConnectedAt(?\DateTimeInterface $connectedAt): self
{
$this->connectedAt = $connectedAt;
return $this;
}
}