namespace Wallabag\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
+use Symfony\Component\Security\Core\User\UserInterface;
+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 integer
+ * @return integer
*/
public function getId()
{
/**
* Set username
*
- * @param string $username
+ * @param string $username
* @return Users
*/
public function setUsername($username)
/**
* Get username
*
- * @return string
+ * @return string
*/
public function getUsername()
{
return $this->username;
}
+ /**
+ * @inheritDoc
+ */
+ public function getSalt()
+ {
+ return $this->salt;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getRoles()
+ {
+ return array('ROLE_USER');
+ }
+
/**
* Set password
*
- * @param string $password
+ * @param string $password
* @return Users
*/
public function setPassword($password)
/**
* Get password
*
- * @return string
+ * @return string
*/
public function getPassword()
{
/**
* Set name
*
- * @param string $name
+ * @param string $name
* @return Users
*/
public function setName($name)
/**
* Get name
*
- * @return string
+ * @return string
*/
public function getName()
{
/**
* Set email
*
- * @param string $email
+ * @param string $email
* @return Users
*/
public function setEmail($email)
/**
* Get email
*
- * @return string
+ * @return string
*/
public function getEmail()
{
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;
+ }
}