]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Entity/Users.php
CS
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / Users.php
index 3db4a3fd954c770755601539026c9bfc2c737b22..e0b1fb39f3e4d5bd54039e8214ecfa8a59de4aaf 100644 (file)
@@ -3,6 +3,8 @@
 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
@@ -10,7 +12,7 @@ use Doctrine\ORM\Mapping as ORM;
  * @ORM\Table(name="users")
  * @ORM\Entity
  */
-class Users
+class Users implements AdvancedUserInterface, \Serializable
 {
     /**
      * @var integer
@@ -28,6 +30,11 @@ class Users
      */
     private $username;
 
+    /**
+     * @ORM\Column(type="string", length=32)
+     */
+    private $salt;
+
     /**
      * @var string
      *
@@ -49,12 +56,21 @@ class Users
      */
     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()
     {
@@ -64,7 +80,7 @@ class Users
     /**
      * Set username
      *
-     * @param string $username
+     * @param  string $username
      * @return Users
      */
     public function setUsername($username)
@@ -77,17 +93,33 @@ class Users
     /**
      * 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)
@@ -100,7 +132,7 @@ class Users
     /**
      * Get password
      *
-     * @return string 
+     * @return string
      */
     public function getPassword()
     {
@@ -110,7 +142,7 @@ class Users
     /**
      * Set name
      *
-     * @param string $name
+     * @param  string $name
      * @return Users
      */
     public function setName($name)
@@ -123,7 +155,7 @@ class Users
     /**
      * Get name
      *
-     * @return string 
+     * @return string
      */
     public function getName()
     {
@@ -133,7 +165,7 @@ class Users
     /**
      * Set email
      *
-     * @param string $email
+     * @param  string $email
      * @return Users
      */
     public function setEmail($email)
@@ -146,10 +178,62 @@ class Users
     /**
      * 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;
+    }
 }