mirror of
https://github.com/wallabag/wallabag.git
synced 2025-10-20 19:52:09 +00:00
first implementation of security
This commit is contained in:
parent
71691fe44a
commit
c3235553dd
18 changed files with 469 additions and 69 deletions
|
@ -10,6 +10,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
*
|
||||
* @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\EntriesRepository")
|
||||
* @ORM\Table(name="entries")
|
||||
*
|
||||
*/
|
||||
class Entries
|
||||
{
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
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
|
||||
|
@ -10,7 +13,7 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
* @ORM\Table(name="users")
|
||||
* @ORM\Entity
|
||||
*/
|
||||
class Users
|
||||
class Users implements AdvancedUserInterface, \Serializable
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
|
@ -28,6 +31,11 @@ class Users
|
|||
*/
|
||||
private $username;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=32)
|
||||
*/
|
||||
private $salt;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
|
@ -49,7 +57,16 @@ 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
|
||||
|
@ -84,6 +101,22 @@ class Users
|
|||
return $this->username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSalt()
|
||||
{
|
||||
return $this->salt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getRoles()
|
||||
{
|
||||
return array('ROLE_USER');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set password
|
||||
*
|
||||
|
@ -152,4 +185,56 @@ class Users
|
|||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue