mirror of
https://github.com/wallabag/wallabag.git
synced 2025-07-22 17:18:37 +00:00
implement FosUser
This commit is contained in:
parent
9c08a891f9
commit
a1691859ca
14 changed files with 138 additions and 307 deletions
|
@ -192,6 +192,7 @@ class InstallCommand extends ContainerAwareCommand
|
|||
$user->setUsername($dialog->ask($this->defaultOutput, '<question>Username</question> <comment>(default: wallabag)</comment> :', 'wallabag'));
|
||||
$user->setPassword($dialog->ask($this->defaultOutput, '<question>Password</question> <comment>(default: wallabag)</comment> :', 'wallabag'));
|
||||
$user->setEmail($dialog->ask($this->defaultOutput, '<question>Email:</question>', ''));
|
||||
$user->setEnabled(true);
|
||||
|
||||
$em->persist($user);
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ class LoadUserData extends AbstractFixture implements OrderedFixtureInterface
|
|||
$userAdmin->setEmail('bigboss@wallabag.org');
|
||||
$userAdmin->setUsername('admin');
|
||||
$userAdmin->setPassword('mypassword');
|
||||
$userAdmin->setEnabled(true);
|
||||
|
||||
$manager->persist($userAdmin);
|
||||
|
||||
|
@ -29,6 +30,7 @@ class LoadUserData extends AbstractFixture implements OrderedFixtureInterface
|
|||
$bobUser->setEmail('bobby@wallabag.org');
|
||||
$bobUser->setUsername('bob');
|
||||
$bobUser->setPassword('mypassword');
|
||||
$bobUser->setEnabled(true);
|
||||
|
||||
$manager->persist($bobUser);
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ use Symfony\Component\Security\Core\User\AdvancedUserInterface;
|
|||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use JMS\Serializer\Annotation\ExclusionPolicy;
|
||||
use JMS\Serializer\Annotation\Expose;
|
||||
use FOS\UserBundle\Model\User as BaseUser;
|
||||
|
||||
/**
|
||||
* User.
|
||||
|
@ -22,7 +23,7 @@ use JMS\Serializer\Annotation\Expose;
|
|||
* @UniqueEntity("email")
|
||||
* @UniqueEntity("username")
|
||||
*/
|
||||
class User implements AdvancedUserInterface, \Serializable
|
||||
class User extends BaseUser implements AdvancedUserInterface, \Serializable
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
|
@ -32,100 +33,49 @@ class User implements AdvancedUserInterface, \Serializable
|
|||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="username", type="text")
|
||||
* @Assert\NotBlank()
|
||||
* @Assert\Length(
|
||||
* min = "3",
|
||||
* max = "255"
|
||||
* )
|
||||
*/
|
||||
private $username;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=32)
|
||||
*/
|
||||
private $salt;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="password", type="text")
|
||||
*/
|
||||
private $password;
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="name", type="text", nullable=true)
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="email", type="text", nullable=false)
|
||||
* @Assert\Email()
|
||||
* @Assert\NotBlank()
|
||||
*/
|
||||
private $email;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="is_active", type="boolean", nullable=false)
|
||||
*/
|
||||
private $isActive = true;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="confirmation_token", type="string", nullable=true)
|
||||
*/
|
||||
private $confirmationToken;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="password_requested_at", type="datetime", nullable=true)
|
||||
*/
|
||||
private $passwordRequestedAt;
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* @var date
|
||||
*
|
||||
* @ORM\Column(name="created_at", type="datetime")
|
||||
*/
|
||||
private $createdAt;
|
||||
protected $createdAt;
|
||||
|
||||
/**
|
||||
* @var date
|
||||
*
|
||||
* @ORM\Column(name="updated_at", type="datetime")
|
||||
*/
|
||||
private $updatedAt;
|
||||
protected $updatedAt;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Entry", mappedBy="user", cascade={"remove"})
|
||||
*/
|
||||
private $entries;
|
||||
protected $entries;
|
||||
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity="Config", mappedBy="user")
|
||||
*/
|
||||
private $config;
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Tag", mappedBy="user", cascade={"remove"})
|
||||
*/
|
||||
private $tags;
|
||||
protected $tags;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->isActive = true;
|
||||
$this->salt = md5(uniqid(null, true));
|
||||
$this->entries = new ArrayCollection();
|
||||
$this->tags = new ArrayCollection();
|
||||
parent::__construct();
|
||||
$this->entries = new ArrayCollection();
|
||||
$this->tags = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -141,56 +91,6 @@ class User implements AdvancedUserInterface, \Serializable
|
|||
$this->updatedAt = new \DateTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set username.
|
||||
*
|
||||
* @param string $username
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function setUsername($username)
|
||||
{
|
||||
$this->username = $username;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get username.
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
|
@ -209,16 +109,6 @@ class User implements AdvancedUserInterface, \Serializable
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get password.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPassword()
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name.
|
||||
*
|
||||
|
@ -243,30 +133,6 @@ class User implements AdvancedUserInterface, \Serializable
|
|||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set email.
|
||||
*
|
||||
* @param string $email
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function setEmail($email)
|
||||
{
|
||||
$this->email = $email;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail()
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
@ -322,56 +188,12 @@ class User implements AdvancedUserInterface, \Serializable
|
|||
{
|
||||
return $this->tags;
|
||||
}
|
||||
/**
|
||||
* {@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;
|
||||
}
|
||||
/**
|
||||
* Set config.
|
||||
*
|
||||
|
@ -395,52 +217,4 @@ class User implements AdvancedUserInterface, \Serializable
|
|||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set confirmationToken.
|
||||
*
|
||||
* @param string $confirmationToken
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function setConfirmationToken($confirmationToken)
|
||||
{
|
||||
$this->confirmationToken = $confirmationToken;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get confirmationToken.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getConfirmationToken()
|
||||
{
|
||||
return $this->confirmationToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set passwordRequestedAt.
|
||||
*
|
||||
* @param \DateTime $passwordRequestedAt
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function setPasswordRequestedAt($passwordRequestedAt)
|
||||
{
|
||||
$this->passwordRequestedAt = $passwordRequestedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get passwordRequestedAt.
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getPasswordRequestedAt()
|
||||
{
|
||||
return $this->passwordRequestedAt;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
</div>
|
||||
|
||||
<div class="row mts txtcenter">
|
||||
<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}" />
|
||||
<button type="submit">Login</button>
|
||||
<a href="{{ path('forgot_password') }}" class="small">Forgot your password?</a>
|
||||
</div>
|
||||
|
|
|
@ -58,7 +58,6 @@
|
|||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
|
||||
<!-- Filters -->
|
||||
<div id="filters" class="side-nav fixed right-aligned">
|
||||
<form action="{{ path('all') }}">
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
|
||||
</div>
|
||||
<div class="card-action">
|
||||
<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}" />
|
||||
<button class="btn waves-effect waves-light" type="submit" name="send">
|
||||
{% trans %}Login{% endtrans %}
|
||||
<i class="mdi-content-send right"></i>
|
||||
|
|
|
@ -75,7 +75,7 @@ class InstallCommandTest extends WallabagCoreTestCase
|
|||
->getMock();
|
||||
$dialog->expects($this->any())
|
||||
->method('ask')
|
||||
->will($this->returnValue('test'));
|
||||
->will($this->returnValue('test2'));
|
||||
$dialog->expects($this->any())
|
||||
->method('askConfirmation')
|
||||
->will($this->returnValue(true));
|
||||
|
|
|
@ -266,7 +266,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
|
|||
array(
|
||||
array(
|
||||
'new_user[username]' => 'ad',
|
||||
'new_user[password]' => '',
|
||||
'new_user[password]' => 'mypassword',
|
||||
'new_user[email]' => '',
|
||||
),
|
||||
'This value is too short.',
|
||||
|
@ -274,7 +274,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
|
|||
array(
|
||||
array(
|
||||
'new_user[username]' => 'wallace',
|
||||
'new_user[password]' => '',
|
||||
'new_user[password]' => 'mypassword',
|
||||
'new_user[email]' => 'test',
|
||||
),
|
||||
'This value is not a valid email address.',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue