aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2015-08-18 11:08:45 +0200
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2015-09-11 20:32:37 +0200
commita1691859ca0cb4c1b360c34b05aa74bdba9e582a (patch)
tree47ef239ea8f452ba4de71f76c9cab607a4dadf8c /src
parent9c08a891f9bb90bc3f23a575a734283c1ee00ba1 (diff)
downloadwallabag-a1691859ca0cb4c1b360c34b05aa74bdba9e582a.tar.gz
wallabag-a1691859ca0cb4c1b360c34b05aa74bdba9e582a.tar.zst
wallabag-a1691859ca0cb4c1b360c34b05aa74bdba9e582a.zip
implement FosUser
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Command/InstallCommand.php1
-rw-r--r--src/Wallabag/CoreBundle/DataFixtures/ORM/LoadUserData.php2
-rw-r--r--src/Wallabag/CoreBundle/Entity/User.php250
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/Security/login.html.twig1
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig1
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Security/login.html.twig1
-rw-r--r--src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php2
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php4
8 files changed, 20 insertions, 242 deletions
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php
index 491c67f9..29d91109 100644
--- a/src/Wallabag/CoreBundle/Command/InstallCommand.php
+++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php
@@ -192,6 +192,7 @@ class InstallCommand extends ContainerAwareCommand
192 $user->setUsername($dialog->ask($this->defaultOutput, '<question>Username</question> <comment>(default: wallabag)</comment> :', 'wallabag')); 192 $user->setUsername($dialog->ask($this->defaultOutput, '<question>Username</question> <comment>(default: wallabag)</comment> :', 'wallabag'));
193 $user->setPassword($dialog->ask($this->defaultOutput, '<question>Password</question> <comment>(default: wallabag)</comment> :', 'wallabag')); 193 $user->setPassword($dialog->ask($this->defaultOutput, '<question>Password</question> <comment>(default: wallabag)</comment> :', 'wallabag'));
194 $user->setEmail($dialog->ask($this->defaultOutput, '<question>Email:</question>', '')); 194 $user->setEmail($dialog->ask($this->defaultOutput, '<question>Email:</question>', ''));
195 $user->setEnabled(true);
195 196
196 $em->persist($user); 197 $em->persist($user);
197 198
diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadUserData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadUserData.php
index 1c7f9dfa..4ef53329 100644
--- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadUserData.php
+++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadUserData.php
@@ -19,6 +19,7 @@ class LoadUserData extends AbstractFixture implements OrderedFixtureInterface
19 $userAdmin->setEmail('bigboss@wallabag.org'); 19 $userAdmin->setEmail('bigboss@wallabag.org');
20 $userAdmin->setUsername('admin'); 20 $userAdmin->setUsername('admin');
21 $userAdmin->setPassword('mypassword'); 21 $userAdmin->setPassword('mypassword');
22 $userAdmin->setEnabled(true);
22 23
23 $manager->persist($userAdmin); 24 $manager->persist($userAdmin);
24 25
@@ -29,6 +30,7 @@ class LoadUserData extends AbstractFixture implements OrderedFixtureInterface
29 $bobUser->setEmail('bobby@wallabag.org'); 30 $bobUser->setEmail('bobby@wallabag.org');
30 $bobUser->setUsername('bob'); 31 $bobUser->setUsername('bob');
31 $bobUser->setPassword('mypassword'); 32 $bobUser->setPassword('mypassword');
33 $bobUser->setEnabled(true);
32 34
33 $manager->persist($bobUser); 35 $manager->persist($bobUser);
34 36
diff --git a/src/Wallabag/CoreBundle/Entity/User.php b/src/Wallabag/CoreBundle/Entity/User.php
index 510a1594..eeae331e 100644
--- a/src/Wallabag/CoreBundle/Entity/User.php
+++ b/src/Wallabag/CoreBundle/Entity/User.php
@@ -10,6 +10,7 @@ use Symfony\Component\Security\Core\User\AdvancedUserInterface;
10use Symfony\Component\Validator\Constraints as Assert; 10use Symfony\Component\Validator\Constraints as Assert;
11use JMS\Serializer\Annotation\ExclusionPolicy; 11use JMS\Serializer\Annotation\ExclusionPolicy;
12use JMS\Serializer\Annotation\Expose; 12use JMS\Serializer\Annotation\Expose;
13use FOS\UserBundle\Model\User as BaseUser;
13 14
14/** 15/**
15 * User. 16 * User.
@@ -22,7 +23,7 @@ use JMS\Serializer\Annotation\Expose;
22 * @UniqueEntity("email") 23 * @UniqueEntity("email")
23 * @UniqueEntity("username") 24 * @UniqueEntity("username")
24 */ 25 */
25class User implements AdvancedUserInterface, \Serializable 26class User extends BaseUser implements AdvancedUserInterface, \Serializable
26{ 27{
27 /** 28 /**
28 * @var int 29 * @var int
@@ -32,100 +33,49 @@ class User implements AdvancedUserInterface, \Serializable
32 * @ORM\Id 33 * @ORM\Id
33 * @ORM\GeneratedValue(strategy="AUTO") 34 * @ORM\GeneratedValue(strategy="AUTO")
34 */ 35 */
35 private $id; 36 protected $id;
36
37 /**
38 * @var string
39 *
40 * @ORM\Column(name="username", type="text")
41 * @Assert\NotBlank()
42 * @Assert\Length(
43 * min = "3",
44 * max = "255"
45 * )
46 */
47 private $username;
48
49 /**
50 * @var string
51 *
52 * @ORM\Column(type="string", length=32)
53 */
54 private $salt;
55
56 /**
57 * @var string
58 *
59 * @ORM\Column(name="password", type="text")
60 */
61 private $password;
62 37
63 /** 38 /**
64 * @var string 39 * @var string
65 * 40 *
66 * @ORM\Column(name="name", type="text", nullable=true) 41 * @ORM\Column(name="name", type="text", nullable=true)
67 */ 42 */
68 private $name; 43 protected $name;
69
70 /**
71 * @var string
72 *
73 * @ORM\Column(name="email", type="text", nullable=false)
74 * @Assert\Email()
75 * @Assert\NotBlank()
76 */
77 private $email;
78
79 /**
80 * @ORM\Column(name="is_active", type="boolean", nullable=false)
81 */
82 private $isActive = true;
83
84 /**
85 * @ORM\Column(name="confirmation_token", type="string", nullable=true)
86 */
87 private $confirmationToken;
88
89 /**
90 * @ORM\Column(name="password_requested_at", type="datetime", nullable=true)
91 */
92 private $passwordRequestedAt;
93 44
94 /** 45 /**
95 * @var date 46 * @var date
96 * 47 *
97 * @ORM\Column(name="created_at", type="datetime") 48 * @ORM\Column(name="created_at", type="datetime")
98 */ 49 */
99 private $createdAt; 50 protected $createdAt;
100 51
101 /** 52 /**
102 * @var date 53 * @var date
103 * 54 *
104 * @ORM\Column(name="updated_at", type="datetime") 55 * @ORM\Column(name="updated_at", type="datetime")
105 */ 56 */
106 private $updatedAt; 57 protected $updatedAt;
107 58
108 /** 59 /**
109 * @ORM\OneToMany(targetEntity="Entry", mappedBy="user", cascade={"remove"}) 60 * @ORM\OneToMany(targetEntity="Entry", mappedBy="user", cascade={"remove"})
110 */ 61 */
111 private $entries; 62 protected $entries;
112 63
113 /** 64 /**
114 * @ORM\OneToOne(targetEntity="Config", mappedBy="user") 65 * @ORM\OneToOne(targetEntity="Config", mappedBy="user")
115 */ 66 */
116 private $config; 67 protected $config;
117 68
118 /** 69 /**
119 * @ORM\OneToMany(targetEntity="Tag", mappedBy="user", cascade={"remove"}) 70 * @ORM\OneToMany(targetEntity="Tag", mappedBy="user", cascade={"remove"})
120 */ 71 */
121 private $tags; 72 protected $tags;
122 73
123 public function __construct() 74 public function __construct()
124 { 75 {
125 $this->isActive = true; 76 parent::__construct();
126 $this->salt = md5(uniqid(null, true)); 77 $this->entries = new ArrayCollection();
127 $this->entries = new ArrayCollection(); 78 $this->tags = new ArrayCollection();
128 $this->tags = new ArrayCollection();
129 } 79 }
130 80
131 /** 81 /**
@@ -142,56 +92,6 @@ class User implements AdvancedUserInterface, \Serializable
142 } 92 }
143 93
144 /** 94 /**
145 * Get id.
146 *
147 * @return int
148 */
149 public function getId()
150 {
151 return $this->id;
152 }
153
154 /**
155 * Set username.
156 *
157 * @param string $username
158 *
159 * @return User
160 */
161 public function setUsername($username)
162 {
163 $this->username = $username;
164
165 return $this;
166 }
167
168 /**
169 * Get username.
170 *
171 * @return string
172 */
173 public function getUsername()
174 {
175 return $this->username;
176 }
177
178 /**
179 * {@inheritdoc}
180 */
181 public function getSalt()
182 {
183 return $this->salt;
184 }
185
186 /**
187 * {@inheritdoc}
188 */
189 public function getRoles()
190 {
191 return array('ROLE_USER');
192 }
193
194 /**
195 * Set password. 95 * Set password.
196 * 96 *
197 * @param string $password 97 * @param string $password
@@ -210,16 +110,6 @@ class User implements AdvancedUserInterface, \Serializable
210 } 110 }
211 111
212 /** 112 /**
213 * Get password.
214 *
215 * @return string
216 */
217 public function getPassword()
218 {
219 return $this->password;
220 }
221
222 /**
223 * Set name. 113 * Set name.
224 * 114 *
225 * @param string $name 115 * @param string $name
@@ -244,30 +134,6 @@ class User implements AdvancedUserInterface, \Serializable
244 } 134 }
245 135
246 /** 136 /**
247 * Set email.
248 *
249 * @param string $email
250 *
251 * @return User
252 */
253 public function setEmail($email)
254 {
255 $this->email = $email;
256
257 return $this;
258 }
259
260 /**
261 * Get email.
262 *
263 * @return string
264 */
265 public function getEmail()
266 {
267 return $this->email;
268 }
269
270 /**
271 * @return string 137 * @return string
272 */ 138 */
273 public function getCreatedAt() 139 public function getCreatedAt()
@@ -322,56 +188,12 @@ class User implements AdvancedUserInterface, \Serializable
322 { 188 {
323 return $this->tags; 189 return $this->tags;
324 } 190 }
325 /**
326 * {@inheritdoc}
327 */
328 public function eraseCredentials()
329 {
330 }
331
332 /**
333 * @see \Serializable::serialize()
334 */
335 public function serialize()
336 {
337 return serialize(array(
338 $this->id,
339 ));
340 }
341
342 /**
343 * @see \Serializable::unserialize()
344 */
345 public function unserialize($serialized)
346 {
347 list(
348 $this->id) = unserialize($serialized);
349 }
350 191
351 public function isEqualTo(UserInterface $user) 192 public function isEqualTo(UserInterface $user)
352 { 193 {
353 return $this->username === $user->getUsername(); 194 return $this->username === $user->getUsername();
354 } 195 }
355 196
356 public function isAccountNonExpired()
357 {
358 return true;
359 }
360
361 public function isAccountNonLocked()
362 {
363 return true;
364 }
365
366 public function isCredentialsNonExpired()
367 {
368 return true;
369 }
370
371 public function isEnabled()
372 {
373 return $this->isActive;
374 }
375 /** 197 /**
376 * Set config. 198 * Set config.
377 * 199 *
@@ -395,52 +217,4 @@ class User implements AdvancedUserInterface, \Serializable
395 { 217 {
396 return $this->config; 218 return $this->config;
397 } 219 }
398
399 /**
400 * Set confirmationToken.
401 *
402 * @param string $confirmationToken
403 *
404 * @return User
405 */
406 public function setConfirmationToken($confirmationToken)
407 {
408 $this->confirmationToken = $confirmationToken;
409
410 return $this;
411 }
412
413 /**
414 * Get confirmationToken.
415 *
416 * @return string
417 */
418 public function getConfirmationToken()
419 {
420 return $this->confirmationToken;
421 }
422
423 /**
424 * Set passwordRequestedAt.
425 *
426 * @param \DateTime $passwordRequestedAt
427 *
428 * @return User
429 */
430 public function setPasswordRequestedAt($passwordRequestedAt)
431 {
432 $this->passwordRequestedAt = $passwordRequestedAt;
433
434 return $this;
435 }
436
437 /**
438 * Get passwordRequestedAt.
439 *
440 * @return \DateTime
441 */
442 public function getPasswordRequestedAt()
443 {
444 return $this->passwordRequestedAt;
445 }
446} 220}
diff --git a/src/Wallabag/CoreBundle/Resources/views/Security/login.html.twig b/src/Wallabag/CoreBundle/Resources/views/Security/login.html.twig
index f669574e..5437d20c 100644
--- a/src/Wallabag/CoreBundle/Resources/views/Security/login.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/Security/login.html.twig
@@ -30,6 +30,7 @@
30 </div> 30 </div>
31 31
32 <div class="row mts txtcenter"> 32 <div class="row mts txtcenter">
33 <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}" />
33 <button type="submit">Login</button> 34 <button type="submit">Login</button>
34 <a href="{{ path('forgot_password') }}" class="small">Forgot your password?</a> 35 <a href="{{ path('forgot_password') }}" class="small">Forgot your password?</a>
35 </div> 36 </div>
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig
index 3711f6e5..1ecaecc5 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig
@@ -58,7 +58,6 @@
58 {% endfor %} 58 {% endfor %}
59 </ul> 59 </ul>
60 60
61
62 <!-- Filters --> 61 <!-- Filters -->
63 <div id="filters" class="side-nav fixed right-aligned"> 62 <div id="filters" class="side-nav fixed right-aligned">
64 <form action="{{ path('all') }}"> 63 <form action="{{ path('all') }}">
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Security/login.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Security/login.html.twig
index 2c513ffe..c9979198 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Security/login.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Security/login.html.twig
@@ -44,6 +44,7 @@
44 44
45 </div> 45 </div>
46 <div class="card-action"> 46 <div class="card-action">
47 <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}" />
47 <button class="btn waves-effect waves-light" type="submit" name="send"> 48 <button class="btn waves-effect waves-light" type="submit" name="send">
48 {% trans %}Login{% endtrans %} 49 {% trans %}Login{% endtrans %}
49 <i class="mdi-content-send right"></i> 50 <i class="mdi-content-send right"></i>
diff --git a/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php b/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php
index 7a819953..3067e5a4 100644
--- a/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php
@@ -75,7 +75,7 @@ class InstallCommandTest extends WallabagCoreTestCase
75 ->getMock(); 75 ->getMock();
76 $dialog->expects($this->any()) 76 $dialog->expects($this->any())
77 ->method('ask') 77 ->method('ask')
78 ->will($this->returnValue('test')); 78 ->will($this->returnValue('test2'));
79 $dialog->expects($this->any()) 79 $dialog->expects($this->any())
80 ->method('askConfirmation') 80 ->method('askConfirmation')
81 ->will($this->returnValue(true)); 81 ->will($this->returnValue(true));
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
index 5ab9c329..e11da935 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
@@ -266,7 +266,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
266 array( 266 array(
267 array( 267 array(
268 'new_user[username]' => 'ad', 268 'new_user[username]' => 'ad',
269 'new_user[password]' => '', 269 'new_user[password]' => 'mypassword',
270 'new_user[email]' => '', 270 'new_user[email]' => '',
271 ), 271 ),
272 'This value is too short.', 272 'This value is too short.',
@@ -274,7 +274,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
274 array( 274 array(
275 array( 275 array(
276 'new_user[username]' => 'wallace', 276 'new_user[username]' => 'wallace',
277 'new_user[password]' => '', 277 'new_user[password]' => 'mypassword',
278 'new_user[email]' => 'test', 278 'new_user[email]' => 'test',
279 ), 279 ),
280 'This value is not a valid email address.', 280 'This value is not a valid email address.',