Для меня не пользовательская система аутентификации, вам просто нужно изменить тело метода getPassword
.ниже вы найдете пример.
password.php
<?php
namespace your\name\space;
use Doctrine\ORM\Mapping as ORM;
use DateTime;
class Password
{
/**
* @ORM\ManyToOne(targetEntity="your\name\space\User", inversedBy="passwords")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false)
*
* @var User
*/
private $user;
/**
* @ORM\Column(name="inserted_at", type="datetime")
*
* @var DateTime
*/
private $insertedAt;
}
User.php
<?php
namespace your\name\space;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
class User implements UserInterface
{
/**
* @ORM\OneToMany(targetEntity="your\name\space\Password", mappedBy="user")
* @ORM\OrderBy(value={"insertedAt" = "DESC"})
*
* @var Collection
*/
private $passwords;
/**
* User constructor.
*/
public function __construct()
{
$this->passwords = new ArrayCollection();
}
/**
* {@inheritDoc}
*/
public function getPassword()
{
if ($this->passwords->isEmpty()) {
return null;
}
return $this->passwords->first();
}
}