<?php
namespace App\Entity;
use App\Utils\ExtendedEntity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
*/
class User implements UserInterface
{
use ExtendedEntity;
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/** @ORM\Column(type="string", length=128, unique=true) */
private $username;
/** @ORM\Column(type="string", length=255, nullable=true) */
private $password;
/** @ORM\Column(type="array", nullable=true) */
private $roles = [];
/** @ORM\Column(type="string", length=255, nullable=true) */
private $salt;
/** @ORM\Column(type="datetime", nullable=true) */
private $lastLogin;
/** @ORM\Column(type="string", length=128, nullable=true) */
private $resetPasswordKey;
public function __construct(string $username = null) {
$this->username = $username;
$this->salt = md5(uniqid('salt', true));
$this->createdAt = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(string $username)
{
$this->username = $username;
return $this;
}
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(?string $password)
{
$this->password = $password;
return $this;
}
public function setRoles(array $roles)
{
$this->roles = $roles;
}
public function eraseCredentials()
{
}
public function getRoles() {
return $this->roles;
}
public function getSalt() {
return $this->salt;
}
public function getLastLogin() : ?\DateTime
{
return $this->lastLogin;
}
public function setLastLogin(\DateTime $lastLogin)
{
$this->lastLogin = $lastLogin;
}
public function getResetPasswordKey() : ?string
{
return $this->resetPasswordKey;
}
public function setResetPasswordKey(?string $resetPasswordKey)
{
$this->resetPasswordKey = $resetPasswordKey;
}
}