namespace Wallabag\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
+use Symfony\Component\Security\Core\User\UserInterface;
+use Symfony\Component\Security\Core\User\EquatableInterface;
+use Symfony\Component\Security\Core\User\AdvancedUserInterface;
/**
* Users
* @ORM\Table(name="users")
* @ORM\Entity
*/
-class Users
+class Users implements AdvancedUserInterface, \Serializable
{
/**
* @var integer
*/
private $username;
+ /**
+ * @ORM\Column(type="string", length=32)
+ */
+ private $salt;
+
/**
* @var string
*
*/
private $email;
+ /**
+ * @ORM\Column(name="is_active", type="boolean")
+ */
+ private $isActive;
+ public function __construct()
+ {
+ $this->isActive = true;
+ $this->salt = md5(uniqid(null, true));
+ }
/**
* Get id
return $this->username;
}
+ /**
+ * @inheritDoc
+ */
+ public function getSalt()
+ {
+ return $this->salt;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getRoles()
+ {
+ return array('ROLE_USER');
+ }
+
/**
* Set password
*
{
return $this->email;
}
+
+ /**
+ * @inheritDoc
+ */
+ public function eraseCredentials()
+ {
+ }
+
+ /**
+ * @see \Serializable::serialize()
+ */
+ public function serialize()
+ {
+ return serialize(array(
+ $this->id,
+ ));
+ }
+
+ /**
+ * @see \Serializable::unserialize()
+ */
+ public function unserialize($serialized)
+ {
+ list (
+ $this->id,
+ ) = unserialize($serialized);
+ }
+
+ public function isEqualTo(UserInterface $user)
+ {
+ return $this->username === $user->getUsername();
+ }
+
+ public function isAccountNonExpired()
+ {
+ return true;
+ }
+
+ public function isAccountNonLocked()
+ {
+ return true;
+ }
+
+ public function isCredentialsNonExpired()
+ {
+ return true;
+ }
+
+ public function isEnabled()
+ {
+ return $this->isActive;
+ }
}