aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle
diff options
context:
space:
mode:
authorJeremy Benoist <j0k3r@users.noreply.github.com>2015-10-06 09:19:06 +0200
committerJeremy Benoist <j0k3r@users.noreply.github.com>2015-10-06 09:19:06 +0200
commit16dabc326311f084d671be188c7941bbb3c341c9 (patch)
tree3210a7688ea2bfa1bff5fd0422b52adf570edcdc /src/Wallabag/CoreBundle
parentfdef5f460524215d806e244e5546865f4b8e01df (diff)
parent8263e71192989dc0fd28a41ac22f9c5b32eb11c4 (diff)
downloadwallabag-16dabc326311f084d671be188c7941bbb3c341c9.tar.gz
wallabag-16dabc326311f084d671be188c7941bbb3c341c9.tar.zst
wallabag-16dabc326311f084d671be188c7941bbb3c341c9.zip
Merge pull request #1436 from wallabag/v2-register
Public registration & oAuth2 \o/
Diffstat (limited to 'src/Wallabag/CoreBundle')
-rw-r--r--src/Wallabag/CoreBundle/Command/InstallCommand.php7
-rw-r--r--src/Wallabag/CoreBundle/Controller/ConfigController.php17
-rw-r--r--src/Wallabag/CoreBundle/Controller/RssController.php8
-rw-r--r--src/Wallabag/CoreBundle/Controller/SecurityController.php153
-rw-r--r--src/Wallabag/CoreBundle/DataFixtures/ORM/LoadUserData.php49
-rw-r--r--src/Wallabag/CoreBundle/Entity/Config.php10
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php5
-rw-r--r--src/Wallabag/CoreBundle/Entity/Tag.php4
-rw-r--r--src/Wallabag/CoreBundle/Entity/User.php219
-rw-r--r--src/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListener.php50
-rw-r--r--src/Wallabag/CoreBundle/Filter/EntryFilterType.php2
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/ForgotPasswordType.php54
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/NewUserType.php5
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/ResetPasswordType.php35
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/UserInformationType.php2
-rw-r--r--src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php2
-rw-r--r--src/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverter.php4
-rw-r--r--src/Wallabag/CoreBundle/Repository/UserRepository.php26
-rw-r--r--src/Wallabag/CoreBundle/Resources/config/services.yml19
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/base.html.twig4
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig16
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/baggy/Security/checkEmail.html.twig17
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/baggy/Security/forgotPassword.html.twig31
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/baggy/Security/login.html.twig39
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/baggy/Security/reset.html.twig35
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig2
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig19
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Security/login.html.twig3
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig3
-rwxr-xr-xsrc/Wallabag/CoreBundle/Resources/views/themes/material/public/css/main.css9
-rwxr-xr-xsrc/Wallabag/CoreBundle/Resources/views/themes/material/public/img/logo-other_themes.pngbin3922 -> 3058 bytes
-rw-r--r--src/Wallabag/CoreBundle/Security/Authentication/Encoder/WallabagPasswordEncoder.php87
-rw-r--r--src/Wallabag/CoreBundle/Security/Authentication/Provider/WallabagAuthenticationProvider.php89
-rw-r--r--src/Wallabag/CoreBundle/Security/Validator/WallabagUserPasswordValidator.php51
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php28
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/RssControllerTest.php6
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php201
-rw-r--r--src/Wallabag/CoreBundle/Tests/EventListener/RegistrationConfirmedListenerTest.php92
-rw-r--r--src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php2
-rw-r--r--src/Wallabag/CoreBundle/Tests/ParamConverter/UsernameRssTokenConverterTest.php26
40 files changed, 275 insertions, 1156 deletions
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php
index 1bd76ae3..6ebbd93c 100644
--- a/src/Wallabag/CoreBundle/Command/InstallCommand.php
+++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php
@@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputOption;
8use Symfony\Component\Console\Input\ArrayInput; 8use Symfony\Component\Console\Input\ArrayInput;
9use Symfony\Component\Console\Output\OutputInterface; 9use Symfony\Component\Console\Output\OutputInterface;
10use Symfony\Component\Console\Output\NullOutput; 10use Symfony\Component\Console\Output\NullOutput;
11use Wallabag\CoreBundle\Entity\User; 11use Wallabag\UserBundle\Entity\User;
12use Wallabag\CoreBundle\Entity\Config; 12use Wallabag\CoreBundle\Entity\Config;
13 13
14class InstallCommand extends ContainerAwareCommand 14class InstallCommand extends ContainerAwareCommand
@@ -188,9 +188,10 @@ class InstallCommand extends ContainerAwareCommand
188 188
189 $em = $this->getContainer()->get('doctrine.orm.entity_manager'); 189 $em = $this->getContainer()->get('doctrine.orm.entity_manager');
190 190
191 $user = new User(); 191 $userManager = $this->getContainer()->get('fos_user.user_manager');
192 $user = $userManager->createUser();
192 $user->setUsername($dialog->ask($this->defaultOutput, '<question>Username</question> <comment>(default: wallabag)</comment> :', 'wallabag')); 193 $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')); 194 $user->setPlainPassword($dialog->ask($this->defaultOutput, '<question>Password</question> <comment>(default: wallabag)</comment> :', 'wallabag'));
194 $user->setEmail($dialog->ask($this->defaultOutput, '<question>Email:</question>', '')); 195 $user->setEmail($dialog->ask($this->defaultOutput, '<question>Email:</question>', ''));
195 $user->setEnabled(true); 196 $user->setEnabled(true);
196 197
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index 5affdee8..ecfecc66 100644
--- a/src/Wallabag/CoreBundle/Controller/ConfigController.php
+++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php
@@ -7,7 +7,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request; 7use Symfony\Component\HttpFoundation\Request;
8use Symfony\Component\HttpFoundation\JsonResponse; 8use Symfony\Component\HttpFoundation\JsonResponse;
9use Wallabag\CoreBundle\Entity\Config; 9use Wallabag\CoreBundle\Entity\Config;
10use Wallabag\CoreBundle\Entity\User; 10use Wallabag\UserBundle\Entity\User;
11use Wallabag\CoreBundle\Form\Type\ChangePasswordType; 11use Wallabag\CoreBundle\Form\Type\ChangePasswordType;
12use Wallabag\CoreBundle\Form\Type\UserInformationType; 12use Wallabag\CoreBundle\Form\Type\UserInformationType;
13use Wallabag\CoreBundle\Form\Type\NewUserType; 13use Wallabag\CoreBundle\Form\Type\NewUserType;
@@ -25,6 +25,7 @@ class ConfigController extends Controller
25 { 25 {
26 $em = $this->getDoctrine()->getManager(); 26 $em = $this->getDoctrine()->getManager();
27 $config = $this->getConfig(); 27 $config = $this->getConfig();
28 $userManager = $this->container->get('fos_user.user_manager');
28 $user = $this->getUser(); 29 $user = $this->getUser();
29 30
30 // handle basic config detail (this form is defined as a service) 31 // handle basic config detail (this form is defined as a service)
@@ -52,9 +53,8 @@ class ConfigController extends Controller
52 $pwdForm->handleRequest($request); 53 $pwdForm->handleRequest($request);
53 54
54 if ($pwdForm->isValid()) { 55 if ($pwdForm->isValid()) {
55 $user->setPassword($pwdForm->get('new_password')->getData()); 56 $user->setPlainPassword($pwdForm->get('new_password')->getData());
56 $em->persist($user); 57 $userManager->updateUser($user, true);
57 $em->flush();
58 58
59 $this->get('session')->getFlashBag()->add( 59 $this->get('session')->getFlashBag()->add(
60 'notice', 60 'notice',
@@ -69,8 +69,7 @@ class ConfigController extends Controller
69 $userForm->handleRequest($request); 69 $userForm->handleRequest($request);
70 70
71 if ($userForm->isValid()) { 71 if ($userForm->isValid()) {
72 $em->persist($user); 72 $userManager->updateUser($user, true);
73 $em->flush();
74 73
75 $this->get('session')->getFlashBag()->add( 74 $this->get('session')->getFlashBag()->add(
76 'notice', 75 'notice',
@@ -97,14 +96,14 @@ class ConfigController extends Controller
97 } 96 }
98 97
99 // handle adding new user 98 // handle adding new user
100 $newUser = new User(); 99 $newUser = $userManager->createUser();
101 // enable created user by default 100 // enable created user by default
102 $newUser->setEnabled(true); 101 $newUser->setEnabled(true);
103 $newUserForm = $this->createForm(new NewUserType(), $newUser, array('validation_groups' => array('Profile'))); 102 $newUserForm = $this->createForm(new NewUserType(), $newUser, array('validation_groups' => array('Profile')));
104 $newUserForm->handleRequest($request); 103 $newUserForm->handleRequest($request);
105 104
106 if ($newUserForm->isValid()) { 105 if ($newUserForm->isValid() && $this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN')) {
107 $em->persist($newUser); 106 $userManager->updateUser($newUser, true);
108 107
109 $config = new Config($newUser); 108 $config = new Config($newUser);
110 $config->setTheme($this->container->getParameter('theme')); 109 $config->setTheme($this->container->getParameter('theme'));
diff --git a/src/Wallabag/CoreBundle/Controller/RssController.php b/src/Wallabag/CoreBundle/Controller/RssController.php
index 6121f361..023a6228 100644
--- a/src/Wallabag/CoreBundle/Controller/RssController.php
+++ b/src/Wallabag/CoreBundle/Controller/RssController.php
@@ -5,7 +5,7 @@ namespace Wallabag\CoreBundle\Controller;
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; 6use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
7use Symfony\Bundle\FrameworkBundle\Controller\Controller; 7use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8use Wallabag\CoreBundle\Entity\User; 8use Wallabag\UserBundle\Entity\User;
9use Wallabag\CoreBundle\Entity\Entry; 9use Wallabag\CoreBundle\Entity\Entry;
10use Pagerfanta\Adapter\DoctrineORMAdapter; 10use Pagerfanta\Adapter\DoctrineORMAdapter;
11use Pagerfanta\Pagerfanta; 11use Pagerfanta\Pagerfanta;
@@ -16,7 +16,7 @@ class RssController extends Controller
16 * Shows unread entries for current user. 16 * Shows unread entries for current user.
17 * 17 *
18 * @Route("/{username}/{token}/unread.xml", name="unread_rss", defaults={"_format"="xml"}) 18 * @Route("/{username}/{token}/unread.xml", name="unread_rss", defaults={"_format"="xml"})
19 * @ParamConverter("user", class="WallabagCoreBundle:User", converter="username_rsstoken_converter") 19 * @ParamConverter("user", class="WallabagUserBundle:User", converter="username_rsstoken_converter")
20 * 20 *
21 * @return \Symfony\Component\HttpFoundation\Response 21 * @return \Symfony\Component\HttpFoundation\Response
22 */ 22 */
@@ -29,7 +29,7 @@ class RssController extends Controller
29 * Shows read entries for current user. 29 * Shows read entries for current user.
30 * 30 *
31 * @Route("/{username}/{token}/archive.xml", name="archive_rss") 31 * @Route("/{username}/{token}/archive.xml", name="archive_rss")
32 * @ParamConverter("user", class="WallabagCoreBundle:User", converter="username_rsstoken_converter") 32 * @ParamConverter("user", class="WallabagUserBundle:User", converter="username_rsstoken_converter")
33 * 33 *
34 * @return \Symfony\Component\HttpFoundation\Response 34 * @return \Symfony\Component\HttpFoundation\Response
35 */ 35 */
@@ -42,7 +42,7 @@ class RssController extends Controller
42 * Shows starred entries for current user. 42 * Shows starred entries for current user.
43 * 43 *
44 * @Route("/{username}/{token}/starred.xml", name="starred_rss") 44 * @Route("/{username}/{token}/starred.xml", name="starred_rss")
45 * @ParamConverter("user", class="WallabagCoreBundle:User", converter="username_rsstoken_converter") 45 * @ParamConverter("user", class="WallabagUserBundle:User", converter="username_rsstoken_converter")
46 * 46 *
47 * @return \Symfony\Component\HttpFoundation\Response 47 * @return \Symfony\Component\HttpFoundation\Response
48 */ 48 */
diff --git a/src/Wallabag/CoreBundle/Controller/SecurityController.php b/src/Wallabag/CoreBundle/Controller/SecurityController.php
deleted file mode 100644
index f0a7ab6d..00000000
--- a/src/Wallabag/CoreBundle/Controller/SecurityController.php
+++ /dev/null
@@ -1,153 +0,0 @@
1<?php
2
3namespace Wallabag\CoreBundle\Controller;
4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
7use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8use Symfony\Component\HttpFoundation\Request;
9use Symfony\Component\Security\Core\SecurityContext;
10use Wallabag\CoreBundle\Form\Type\ResetPasswordType;
11
12class SecurityController extends Controller
13{
14 public function loginAction(Request $request)
15 {
16 $session = $request->getSession();
17 // get the login error if there is one
18 if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
19 $error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
20 } else {
21 $error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
22 $session->remove(SecurityContext::AUTHENTICATION_ERROR);
23 }
24
25 return $this->render('WallabagCoreBundle:Security:login.html.twig', array(
26 // last username entered by the user
27 'last_username' => $session->get(SecurityContext::LAST_USERNAME),
28 'error' => $error,
29 ));
30 }
31
32 /**
33 * Request forgot password: show form.
34 *
35 * @Route("/forgot-password", name="forgot_password")
36 *
37 * @Method({"GET", "POST"})
38 */
39 public function forgotPasswordAction(Request $request)
40 {
41 $form = $this->createForm('forgot_password');
42 $form->handleRequest($request);
43
44 if ($form->isValid()) {
45 $user = $this->getDoctrine()->getRepository('WallabagCoreBundle:User')->findOneByEmail($form->get('email')->getData());
46
47 // generate "hard" token
48 $user->setConfirmationToken(rtrim(strtr(base64_encode(hash('sha256', uniqid(mt_rand(), true), true)), '+/', '-_'), '='));
49 $user->setPasswordRequestedAt(new \DateTime());
50
51 $em = $this->getDoctrine()->getManager();
52 $em->persist($user);
53 $em->flush();
54
55 $message = \Swift_Message::newInstance()
56 ->setSubject('Reset Password')
57 ->setFrom($this->container->getParameter('from_email'))
58 ->setTo($user->getEmail())
59 ->setBody($this->renderView('WallabagCoreBundle:Mail:forgotPassword.txt.twig', array(
60 'username' => $user->getUsername(),
61 'confirmationUrl' => $this->generateUrl('forgot_password_reset', array('token' => $user->getConfirmationToken()), true),
62 )))
63 ;
64 $this->get('mailer')->send($message);
65
66 return $this->redirect($this->generateUrl('forgot_password_check_email',
67 array('email' => $this->getObfuscatedEmail($user->getEmail()))
68 ));
69 }
70
71 return $this->render('WallabagCoreBundle:Security:forgotPassword.html.twig', array(
72 'form' => $form->createView(),
73 ));
74 }
75
76 /**
77 * Tell the user to check his email provider.
78 *
79 * @Route("/forgot-password/check-email", name="forgot_password_check_email")
80 *
81 * @Method({"GET"})
82 */
83 public function checkEmailAction(Request $request)
84 {
85 $email = $request->query->get('email');
86
87 if (empty($email)) {
88 // the user does not come from the forgotPassword action
89 return $this->redirect($this->generateUrl('forgot_password'));
90 }
91
92 return $this->render('WallabagCoreBundle:Security:checkEmail.html.twig', array(
93 'email' => $email,
94 ));
95 }
96
97 /**
98 * Reset user password.
99 *
100 * @Route("/forgot-password/{token}", name="forgot_password_reset")
101 *
102 * @Method({"GET", "POST"})
103 */
104 public function resetAction(Request $request, $token)
105 {
106 $user = $this->getDoctrine()->getRepository('WallabagCoreBundle:User')->findOneByConfirmationToken($token);
107
108 if (null === $user) {
109 throw $this->createNotFoundException(sprintf('No user found with token "%s"', $token));
110 }
111
112 $form = $this->createForm(new ResetPasswordType());
113 $form->handleRequest($request);
114
115 if ($form->isValid()) {
116 $user->setPassword($form->get('new_password')->getData());
117
118 $em = $this->getDoctrine()->getManager();
119 $em->persist($user);
120 $em->flush();
121
122 $this->get('session')->getFlashBag()->add(
123 'notice',
124 'The password has been reset successfully'
125 );
126
127 return $this->redirect($this->generateUrl('login'));
128 }
129
130 return $this->render('WallabagCoreBundle:Security:reset.html.twig', array(
131 'token' => $token,
132 'form' => $form->createView(),
133 ));
134 }
135
136 /**
137 * Get the truncated email displayed when requesting the resetting.
138 *
139 * Keeping only the part following @ in the address.
140 *
141 * @param string $email
142 *
143 * @return string
144 */
145 protected function getObfuscatedEmail($email)
146 {
147 if (false !== $pos = strpos($email, '@')) {
148 $email = '...'.substr($email, $pos);
149 }
150
151 return $email;
152 }
153}
diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadUserData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadUserData.php
deleted file mode 100644
index 4ef53329..00000000
--- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadUserData.php
+++ /dev/null
@@ -1,49 +0,0 @@
1<?php
2
3namespace Wallabag\CoreBundle\DataFixtures\ORM;
4
5use Doctrine\Common\DataFixtures\AbstractFixture;
6use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
7use Doctrine\Common\Persistence\ObjectManager;
8use Wallabag\CoreBundle\Entity\User;
9
10class LoadUserData extends AbstractFixture implements OrderedFixtureInterface
11{
12 /**
13 * {@inheritdoc}
14 */
15 public function load(ObjectManager $manager)
16 {
17 $userAdmin = new User();
18 $userAdmin->setName('Big boss');
19 $userAdmin->setEmail('bigboss@wallabag.org');
20 $userAdmin->setUsername('admin');
21 $userAdmin->setPassword('mypassword');
22 $userAdmin->setEnabled(true);
23
24 $manager->persist($userAdmin);
25
26 $this->addReference('admin-user', $userAdmin);
27
28 $bobUser = new User();
29 $bobUser->setName('Bobby');
30 $bobUser->setEmail('bobby@wallabag.org');
31 $bobUser->setUsername('bob');
32 $bobUser->setPassword('mypassword');
33 $bobUser->setEnabled(true);
34
35 $manager->persist($bobUser);
36
37 $this->addReference('bob-user', $bobUser);
38
39 $manager->flush();
40 }
41
42 /**
43 * {@inheritdoc}
44 */
45 public function getOrder()
46 {
47 return 10;
48 }
49}
diff --git a/src/Wallabag/CoreBundle/Entity/Config.php b/src/Wallabag/CoreBundle/Entity/Config.php
index 025d94ef..2390bfe1 100644
--- a/src/Wallabag/CoreBundle/Entity/Config.php
+++ b/src/Wallabag/CoreBundle/Entity/Config.php
@@ -72,14 +72,14 @@ class Config
72 private $rssLimit; 72 private $rssLimit;
73 73
74 /** 74 /**
75 * @ORM\OneToOne(targetEntity="User", inversedBy="config") 75 * @ORM\OneToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="config")
76 */ 76 */
77 private $user; 77 private $user;
78 78
79 /* 79 /*
80 * @param User $user 80 * @param User $user
81 */ 81 */
82 public function __construct(User $user) 82 public function __construct(\Wallabag\UserBundle\Entity\User $user)
83 { 83 {
84 $this->user = $user; 84 $this->user = $user;
85 } 85 }
@@ -169,11 +169,11 @@ class Config
169 /** 169 /**
170 * Set user. 170 * Set user.
171 * 171 *
172 * @param \Wallabag\CoreBundle\Entity\User $user 172 * @param User $user
173 * 173 *
174 * @return Config 174 * @return Config
175 */ 175 */
176 public function setUser(\Wallabag\CoreBundle\Entity\User $user = null) 176 public function setUser(User $user = null)
177 { 177 {
178 $this->user = $user; 178 $this->user = $user;
179 179
@@ -183,7 +183,7 @@ class Config
183 /** 183 /**
184 * Get user. 184 * Get user.
185 * 185 *
186 * @return \Wallabag\CoreBundle\Entity\User 186 * @return User
187 */ 187 */
188 public function getUser() 188 public function getUser()
189 { 189 {
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index 9e81ba12..4fd74001 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -7,6 +7,7 @@ use Doctrine\ORM\Mapping as ORM;
7use Symfony\Component\Validator\Constraints as Assert; 7use Symfony\Component\Validator\Constraints as Assert;
8use Hateoas\Configuration\Annotation as Hateoas; 8use Hateoas\Configuration\Annotation as Hateoas;
9use JMS\Serializer\Annotation\XmlRoot; 9use JMS\Serializer\Annotation\XmlRoot;
10use Wallabag\UserBundle\Entity\User;
10 11
11/** 12/**
12 * Entry. 13 * Entry.
@@ -129,7 +130,7 @@ class Entry
129 private $isPublic; 130 private $isPublic;
130 131
131 /** 132 /**
132 * @ORM\ManyToOne(targetEntity="User", inversedBy="entries") 133 * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="entries")
133 */ 134 */
134 private $user; 135 private $user;
135 136
@@ -142,7 +143,7 @@ class Entry
142 /* 143 /*
143 * @param User $user 144 * @param User $user
144 */ 145 */
145 public function __construct(User $user) 146 public function __construct(\Wallabag\UserBundle\Entity\User $user)
146 { 147 {
147 $this->user = $user; 148 $this->user = $user;
148 $this->tags = new ArrayCollection(); 149 $this->tags = new ArrayCollection();
diff --git a/src/Wallabag/CoreBundle/Entity/Tag.php b/src/Wallabag/CoreBundle/Entity/Tag.php
index 97c4579f..5b571823 100644
--- a/src/Wallabag/CoreBundle/Entity/Tag.php
+++ b/src/Wallabag/CoreBundle/Entity/Tag.php
@@ -42,11 +42,11 @@ class Tag
42 private $entries; 42 private $entries;
43 43
44 /** 44 /**
45 * @ORM\ManyToOne(targetEntity="User", inversedBy="tags") 45 * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="tags")
46 */ 46 */
47 private $user; 47 private $user;
48 48
49 public function __construct(User $user) 49 public function __construct(\Wallabag\UserBundle\Entity\User $user)
50 { 50 {
51 $this->user = $user; 51 $this->user = $user;
52 $this->entries = new ArrayCollection(); 52 $this->entries = new ArrayCollection();
diff --git a/src/Wallabag/CoreBundle/Entity/User.php b/src/Wallabag/CoreBundle/Entity/User.php
deleted file mode 100644
index a6002352..00000000
--- a/src/Wallabag/CoreBundle/Entity/User.php
+++ /dev/null
@@ -1,219 +0,0 @@
1<?php
2
3namespace Wallabag\CoreBundle\Entity;
4
5use Doctrine\Common\Collections\ArrayCollection;
6use Doctrine\ORM\Mapping as ORM;
7use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
8use Symfony\Component\Security\Core\User\UserInterface;
9use Symfony\Component\Security\Core\User\AdvancedUserInterface;
10use JMS\Serializer\Annotation\ExclusionPolicy;
11use JMS\Serializer\Annotation\Expose;
12use FOS\UserBundle\Model\User as BaseUser;
13
14/**
15 * User.
16 *
17 * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\UserRepository")
18 * @ORM\Table
19 * @ORM\HasLifecycleCallbacks()
20 * @ExclusionPolicy("all")
21 *
22 * @UniqueEntity("email")
23 * @UniqueEntity("username")
24 */
25class User extends BaseUser implements AdvancedUserInterface, \Serializable
26{
27 /**
28 * @var int
29 *
30 * @Expose
31 * @ORM\Column(name="id", type="integer")
32 * @ORM\Id
33 * @ORM\GeneratedValue(strategy="AUTO")
34 */
35 protected $id;
36
37 /**
38 * @var string
39 *
40 * @ORM\Column(name="name", type="text", nullable=true)
41 */
42 protected $name;
43
44 /**
45 * @var date
46 *
47 * @ORM\Column(name="created_at", type="datetime")
48 */
49 protected $createdAt;
50
51 /**
52 * @var date
53 *
54 * @ORM\Column(name="updated_at", type="datetime")
55 */
56 protected $updatedAt;
57
58 /**
59 * @ORM\OneToMany(targetEntity="Entry", mappedBy="user", cascade={"remove"})
60 */
61 protected $entries;
62
63 /**
64 * @ORM\OneToOne(targetEntity="Config", mappedBy="user")
65 */
66 protected $config;
67
68 /**
69 * @ORM\OneToMany(targetEntity="Tag", mappedBy="user", cascade={"remove"})
70 */
71 protected $tags;
72
73 public function __construct()
74 {
75 parent::__construct();
76 $this->entries = new ArrayCollection();
77 $this->tags = new ArrayCollection();
78 }
79
80 /**
81 * @ORM\PrePersist
82 * @ORM\PreUpdate
83 */
84 public function timestamps()
85 {
86 if (is_null($this->createdAt)) {
87 $this->createdAt = new \DateTime();
88 }
89
90 $this->updatedAt = new \DateTime();
91 }
92
93 /**
94 * Set password.
95 *
96 * @param string $password
97 *
98 * @return User
99 */
100 public function setPassword($password)
101 {
102 if (!$password && 0 === strlen($password)) {
103 return;
104 }
105
106 $this->password = sha1($password.$this->getUsername().$this->getSalt());
107
108 return $this;
109 }
110
111 /**
112 * Set name.
113 *
114 * @param string $name
115 *
116 * @return User
117 */
118 public function setName($name)
119 {
120 $this->name = $name;
121
122 return $this;
123 }
124
125 /**
126 * Get name.
127 *
128 * @return string
129 */
130 public function getName()
131 {
132 return $this->name;
133 }
134
135 /**
136 * @return string
137 */
138 public function getCreatedAt()
139 {
140 return $this->createdAt;
141 }
142
143 /**
144 * @return string
145 */
146 public function getUpdatedAt()
147 {
148 return $this->updatedAt;
149 }
150
151 /**
152 * @param Entry $entry
153 *
154 * @return User
155 */
156 public function addEntry(Entry $entry)
157 {
158 $this->entries[] = $entry;
159
160 return $this;
161 }
162
163 /**
164 * @return ArrayCollection<Entry>
165 */
166 public function getEntries()
167 {
168 return $this->entries;
169 }
170
171 /**
172 * @param Entry $entry
173 *
174 * @return User
175 */
176 public function addTag(Tag $tag)
177 {
178 $this->tags[] = $tag;
179
180 return $this;
181 }
182
183 /**
184 * @return ArrayCollection<Tag>
185 */
186 public function getTags()
187 {
188 return $this->tags;
189 }
190
191 public function isEqualTo(UserInterface $user)
192 {
193 return $this->username === $user->getUsername();
194 }
195
196 /**
197 * Set config.
198 *
199 * @param \Wallabag\CoreBundle\Entity\Config $config
200 *
201 * @return User
202 */
203 public function setConfig(\Wallabag\CoreBundle\Entity\Config $config = null)
204 {
205 $this->config = $config;
206
207 return $this;
208 }
209
210 /**
211 * Get config.
212 *
213 * @return \Wallabag\CoreBundle\Entity\Config
214 */
215 public function getConfig()
216 {
217 return $this->config;
218 }
219}
diff --git a/src/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListener.php b/src/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListener.php
new file mode 100644
index 00000000..68c25f1f
--- /dev/null
+++ b/src/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListener.php
@@ -0,0 +1,50 @@
1<?php
2
3namespace Wallabag\CoreBundle\EventListener;
4
5use Symfony\Component\EventDispatcher\EventDispatcherInterface;
6use Symfony\Component\EventDispatcher\EventSubscriberInterface;
7use Doctrine\ORM\EntityManager;
8use FOS\UserBundle\Event\FilterUserResponseEvent;
9use FOS\UserBundle\FOSUserEvents;
10use Wallabag\CoreBundle\Entity\Config;
11
12class RegistrationConfirmedListener implements EventSubscriberInterface
13{
14 private $em;
15 private $theme;
16 private $itemsOnPage;
17 private $rssLimit;
18 private $language;
19
20 public function __construct(EntityManager $em, $theme, $itemsOnPage, $rssLimit, $language)
21 {
22 $this->em = $em;
23 $this->theme = $theme;
24 $this->itemsOnPage = $itemsOnPage;
25 $this->rssLimit = $rssLimit;
26 $this->language = $language;
27 }
28
29 public static function getSubscribedEvents()
30 {
31 return array(
32 FOSUserEvents::REGISTRATION_CONFIRMED => 'authenticate',
33 );
34 }
35
36 public function authenticate(FilterUserResponseEvent $event, $eventName = null, EventDispatcherInterface $eventDispatcher = null)
37 {
38 if (!$event->getUser()->isEnabled()) {
39 return;
40 }
41
42 $config = new Config($event->getUser());
43 $config->setTheme($this->theme);
44 $config->setItemsPerPage($this->itemsOnPage);
45 $config->setRssLimit($this->rssLimit);
46 $config->setLanguage($this->language);
47 $this->em->persist($config);
48 $this->em->flush();
49 }
50}
diff --git a/src/Wallabag/CoreBundle/Filter/EntryFilterType.php b/src/Wallabag/CoreBundle/Filter/EntryFilterType.php
index 2e6d6ff7..32de21ca 100644
--- a/src/Wallabag/CoreBundle/Filter/EntryFilterType.php
+++ b/src/Wallabag/CoreBundle/Filter/EntryFilterType.php
@@ -7,7 +7,7 @@ use Symfony\Component\Form\FormBuilderInterface;
7use Symfony\Component\OptionsResolver\OptionsResolver; 7use Symfony\Component\OptionsResolver\OptionsResolver;
8use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface; 8use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface;
9use Doctrine\ORM\EntityRepository; 9use Doctrine\ORM\EntityRepository;
10use Wallabag\CoreBundle\Entity\User; 10use Wallabag\UserBundle\Entity\User;
11 11
12class EntryFilterType extends AbstractType 12class EntryFilterType extends AbstractType
13{ 13{
diff --git a/src/Wallabag/CoreBundle/Form/Type/ForgotPasswordType.php b/src/Wallabag/CoreBundle/Form/Type/ForgotPasswordType.php
deleted file mode 100644
index 9e95eb47..00000000
--- a/src/Wallabag/CoreBundle/Form/Type/ForgotPasswordType.php
+++ /dev/null
@@ -1,54 +0,0 @@
1<?php
2
3namespace Wallabag\CoreBundle\Form\Type;
4
5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\FormBuilderInterface;
7use Symfony\Component\Validator\Constraints;
8use Symfony\Component\Validator\ExecutionContextInterface;
9use Doctrine\Bundle\DoctrineBundle\Registry;
10
11class ForgotPasswordType extends AbstractType
12{
13 private $doctrine = null;
14
15 public function __construct(Registry $doctrine)
16 {
17 $this->doctrine = $doctrine;
18 }
19
20 public function buildForm(FormBuilderInterface $builder, array $options)
21 {
22 $builder
23 ->add('email', 'email', array(
24 'required' => true,
25 'constraints' => array(
26 new Constraints\Email(),
27 new Constraints\NotBlank(),
28 new Constraints\Callback(array(array($this, 'validateEmail'))),
29 ),
30 ))
31 ;
32 }
33
34 public function getName()
35 {
36 return 'forgot_password';
37 }
38
39 public function validateEmail($email, ExecutionContextInterface $context)
40 {
41 $user = $this->doctrine
42 ->getRepository('WallabagCoreBundle:User')
43 ->findOneByEmail($email);
44
45 if (!$user) {
46 $context->addViolationAt(
47 'email',
48 'No user found with this email',
49 array(),
50 $email
51 );
52 }
53 }
54}
diff --git a/src/Wallabag/CoreBundle/Form/Type/NewUserType.php b/src/Wallabag/CoreBundle/Form/Type/NewUserType.php
index 985cb55b..8aabc8bb 100644
--- a/src/Wallabag/CoreBundle/Form/Type/NewUserType.php
+++ b/src/Wallabag/CoreBundle/Form/Type/NewUserType.php
@@ -13,7 +13,8 @@ class NewUserType extends AbstractType
13 { 13 {
14 $builder 14 $builder
15 ->add('username', 'text', array('required' => true)) 15 ->add('username', 'text', array('required' => true))
16 ->add('password', 'password', array( 16 ->add('plainPassword', 'repeated', array(
17 'type' => 'password',
17 'constraints' => array( 18 'constraints' => array(
18 new Constraints\Length(array( 19 new Constraints\Length(array(
19 'min' => 8, 20 'min' => 8,
@@ -30,7 +31,7 @@ class NewUserType extends AbstractType
30 public function configureOptions(OptionsResolver $resolver) 31 public function configureOptions(OptionsResolver $resolver)
31 { 32 {
32 $resolver->setDefaults(array( 33 $resolver->setDefaults(array(
33 'data_class' => 'Wallabag\CoreBundle\Entity\User', 34 'data_class' => 'Wallabag\UserBundle\Entity\User',
34 )); 35 ));
35 } 36 }
36 37
diff --git a/src/Wallabag/CoreBundle/Form/Type/ResetPasswordType.php b/src/Wallabag/CoreBundle/Form/Type/ResetPasswordType.php
deleted file mode 100644
index 38f1a105..00000000
--- a/src/Wallabag/CoreBundle/Form/Type/ResetPasswordType.php
+++ /dev/null
@@ -1,35 +0,0 @@
1<?php
2
3namespace Wallabag\CoreBundle\Form\Type;
4
5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\FormBuilderInterface;
7use Symfony\Component\Validator\Constraints;
8
9class ResetPasswordType extends AbstractType
10{
11 public function buildForm(FormBuilderInterface $builder, array $options)
12 {
13 $builder
14 ->add('new_password', 'repeated', array(
15 'type' => 'password',
16 'invalid_message' => 'The password fields must match.',
17 'required' => true,
18 'first_options' => array('label' => 'New password'),
19 'second_options' => array('label' => 'Repeat new password'),
20 'constraints' => array(
21 new Constraints\Length(array(
22 'min' => 8,
23 'minMessage' => 'Password should by at least 8 chars long',
24 )),
25 new Constraints\NotBlank(),
26 ),
27 ))
28 ;
29 }
30
31 public function getName()
32 {
33 return 'change_passwd';
34 }
35}
diff --git a/src/Wallabag/CoreBundle/Form/Type/UserInformationType.php b/src/Wallabag/CoreBundle/Form/Type/UserInformationType.php
index e3196d9c..84f02013 100644
--- a/src/Wallabag/CoreBundle/Form/Type/UserInformationType.php
+++ b/src/Wallabag/CoreBundle/Form/Type/UserInformationType.php
@@ -27,7 +27,7 @@ class UserInformationType extends AbstractType
27 public function configureOptions(OptionsResolver $resolver) 27 public function configureOptions(OptionsResolver $resolver)
28 { 28 {
29 $resolver->setDefaults(array( 29 $resolver->setDefaults(array(
30 'data_class' => 'Wallabag\CoreBundle\Entity\User', 30 'data_class' => 'Wallabag\UserBundle\Entity\User',
31 )); 31 ));
32 } 32 }
33 33
diff --git a/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php b/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php
index 446629db..679186c0 100644
--- a/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php
+++ b/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php
@@ -4,7 +4,7 @@ namespace Wallabag\CoreBundle\Helper;
4 4
5use Liip\ThemeBundle\Helper\DeviceDetectionInterface; 5use Liip\ThemeBundle\Helper\DeviceDetectionInterface;
6use Symfony\Component\Security\Core\SecurityContextInterface; 6use Symfony\Component\Security\Core\SecurityContextInterface;
7use Wallabag\CoreBundle\Entity\User; 7use Wallabag\UserBundle\Entity\User;
8 8
9/** 9/**
10 * This class intend to detect the active theme for the logged in user. 10 * This class intend to detect the active theme for the logged in user.
diff --git a/src/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverter.php b/src/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverter.php
index 2771cf11..f7faa2c1 100644
--- a/src/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverter.php
+++ b/src/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverter.php
@@ -7,7 +7,7 @@ use Doctrine\Common\Persistence\ManagerRegistry;
7use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; 7use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
8use Symfony\Component\HttpFoundation\Request; 8use Symfony\Component\HttpFoundation\Request;
9use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; 9use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
10use Wallabag\CoreBundle\Entity\User; 10use Wallabag\UserBundle\Entity\User;
11 11
12/** 12/**
13 * ParamConverter used in the RSS controller to retrieve the right user according to 13 * ParamConverter used in the RSS controller to retrieve the right user according to
@@ -49,7 +49,7 @@ class UsernameRssTokenConverter implements ParamConverterInterface
49 $em = $this->registry->getManagerForClass($configuration->getClass()); 49 $em = $this->registry->getManagerForClass($configuration->getClass());
50 50
51 // Check, if class name is what we need 51 // Check, if class name is what we need
52 if ('Wallabag\CoreBundle\Entity\User' !== $em->getClassMetadata($configuration->getClass())->getName()) { 52 if ('Wallabag\UserBundle\Entity\User' !== $em->getClassMetadata($configuration->getClass())->getName()) {
53 return false; 53 return false;
54 } 54 }
55 55
diff --git a/src/Wallabag/CoreBundle/Repository/UserRepository.php b/src/Wallabag/CoreBundle/Repository/UserRepository.php
deleted file mode 100644
index 968d0b49..00000000
--- a/src/Wallabag/CoreBundle/Repository/UserRepository.php
+++ /dev/null
@@ -1,26 +0,0 @@
1<?php
2
3namespace Wallabag\CoreBundle\Repository;
4
5use Doctrine\ORM\EntityRepository;
6
7class UserRepository extends EntityRepository
8{
9 /**
10 * Find a user by its username and rss roken.
11 *
12 * @param string $username
13 * @param string $rssToken
14 *
15 * @return User|null
16 */
17 public function findOneByUsernameAndRsstoken($username, $rssToken)
18 {
19 return $this->createQueryBuilder('u')
20 ->leftJoin('u.config', 'c')
21 ->where('c.rssToken = :rss_token')->setParameter('rss_token', $rssToken)
22 ->andWhere('u.username = :username')->setParameter('username', $username)
23 ->getQuery()
24 ->getOneOrNullResult();
25 }
26}
diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml
index 3beb5d0e..c38787de 100644
--- a/src/Wallabag/CoreBundle/Resources/config/services.yml
+++ b/src/Wallabag/CoreBundle/Resources/config/services.yml
@@ -13,6 +13,11 @@ services:
13 tags: 13 tags:
14 - { name: form.type, alias: config } 14 - { name: form.type, alias: config }
15 15
16 wallabag_core.form.registration:
17 class: Wallabag\CoreBundle\Form\Type\RegistrationType
18 tags:
19 - { name: form.type, alias: wallabag_user_registration }
20
16 wallabag_core.form.type.forgot_password: 21 wallabag_core.form.type.forgot_password:
17 class: Wallabag\CoreBundle\Form\Type\ForgotPasswordType 22 class: Wallabag\CoreBundle\Form\Type\ForgotPasswordType
18 arguments: 23 arguments:
@@ -29,7 +34,8 @@ services:
29 34
30 wallabag_core.doctrine.prefixed_naming_strategy: 35 wallabag_core.doctrine.prefixed_naming_strategy:
31 class: Wallabag\CoreBundle\Doctrine\Mapping\PrefixedNamingStrategy 36 class: Wallabag\CoreBundle\Doctrine\Mapping\PrefixedNamingStrategy
32 arguments: [%database_table_prefix%] 37 arguments:
38 - %database_table_prefix%
33 39
34 wallabag_core.graby: 40 wallabag_core.graby:
35 class: Graby\Graby 41 class: Graby\Graby
@@ -40,3 +46,14 @@ services:
40 class: Wallabag\CoreBundle\Helper\ContentProxy 46 class: Wallabag\CoreBundle\Helper\ContentProxy
41 arguments: 47 arguments:
42 - @wallabag_core.graby 48 - @wallabag_core.graby
49
50 wallabag_core.registration_confirmed:
51 class: Wallabag\CoreBundle\EventListener\RegistrationConfirmedListener
52 arguments:
53 - @doctrine.orm.entity_manager
54 - %theme%
55 - %items_on_page%
56 - %rss_limit%
57 - %language%
58 tags:
59 - { name: kernel.event_subscriber }
diff --git a/src/Wallabag/CoreBundle/Resources/views/base.html.twig b/src/Wallabag/CoreBundle/Resources/views/base.html.twig
index 152c5c28..c94c0044 100644
--- a/src/Wallabag/CoreBundle/Resources/views/base.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/base.html.twig
@@ -45,7 +45,7 @@
45 <script src="{{ asset('themes/_global/js/bookmarklet.js') }}"></script> 45 <script src="{{ asset('themes/_global/js/bookmarklet.js') }}"></script>
46 {% endblock %} 46 {% endblock %}
47 47
48 <title>{% block title %}{% endblock %} - wallabag</title> 48 <title>{% block title %}{% endblock %}</title>
49 {% endblock %} 49 {% endblock %}
50 </head> 50 </head>
51 51
@@ -60,7 +60,7 @@
60 60
61 {% block messages %}{% endblock %} 61 {% block messages %}{% endblock %}
62 62
63 <div id="content" class="w600p"> 63 <div id="content">
64 {% block content %}{% endblock %} 64 {% block content %}{% endblock %}
65 </div> 65 </div>
66 </main> 66 </main>
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig
index c90bb2e3..64305b16 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig
@@ -135,6 +135,7 @@
135 {{ form_rest(form.pwd) }} 135 {{ form_rest(form.pwd) }}
136 </form> 136 </form>
137 137
138 {% if is_granted('ROLE_SUPER_ADMIN') %}
138 <h2>{% trans %}Add a user{% endtrans %}</h2> 139 <h2>{% trans %}Add a user{% endtrans %}</h2>
139 140
140 <form action="{{ path('config') }}" method="post" {{ form_enctype(form.new_user) }}> 141 <form action="{{ path('config') }}" method="post" {{ form_enctype(form.new_user) }}>
@@ -150,9 +151,17 @@
150 151
151 <fieldset class="w500p inline"> 152 <fieldset class="w500p inline">
152 <div class="row"> 153 <div class="row">
153 {{ form_label(form.new_user.password) }} 154 {{ form_label(form.new_user.plainPassword.first) }}
154 {{ form_errors(form.new_user.password) }} 155 {{ form_errors(form.new_user.plainPassword.first) }}
155 {{ form_widget(form.new_user.password) }} 156 {{ form_widget(form.new_user.plainPassword.first) }}
157 </div>
158 </fieldset>
159
160 <fieldset class="w500p inline">
161 <div class="row">
162 {{ form_label(form.new_user.plainPassword.second) }}
163 {{ form_errors(form.new_user.plainPassword.second) }}
164 {{ form_widget(form.new_user.plainPassword.second) }}
156 </div> 165 </div>
157 </fieldset> 166 </fieldset>
158 167
@@ -165,5 +174,6 @@
165 </fieldset> 174 </fieldset>
166 175
167 {{ form_rest(form.new_user) }} 176 {{ form_rest(form.new_user) }}
177 {% endif %}
168 </form> 178 </form>
169{% endblock %} 179{% endblock %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Security/checkEmail.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Security/checkEmail.html.twig
deleted file mode 100644
index 056d65b5..00000000
--- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Security/checkEmail.html.twig
+++ /dev/null
@@ -1,17 +0,0 @@
1{% extends "WallabagCoreBundle::layout.html.twig" %}
2
3{% block title %}{% trans %}Forgot password{% endtrans %}{% endblock %}
4
5{% block body_class %}login{% endblock %}
6
7{% block menu %}{% endblock %}
8
9{% block content %}
10 <form>
11 <fieldset class="w500p center">
12 <h2 class="mbs txtcenter">{% trans %}Forgot password{% endtrans %}</h2>
13
14 <p>{{ 'An email has been sent to %email%. It contains a link you must click to reset your password.'|trans({'%email%': email}) }}</p>
15 </fieldset>
16 </form>
17{% endblock %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Security/forgotPassword.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Security/forgotPassword.html.twig
deleted file mode 100644
index 4476ea7b..00000000
--- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Security/forgotPassword.html.twig
+++ /dev/null
@@ -1,31 +0,0 @@
1{% extends "WallabagCoreBundle::layout.html.twig" %}
2
3{% block title %}{% trans %}Forgot password{% endtrans %}{% endblock %}
4
5{% block body_class %}login{% endblock %}
6
7{% block menu %}{% endblock %}
8
9{% block content %}
10 <form action="{{ path('forgot_password') }}" method="post" name="forgotPasswordform">
11 <fieldset class="w500p center">
12 <h2 class="mbs txtcenter">{% trans %}Forgot password{% endtrans %}</h2>
13
14 {{ form_errors(form) }}
15
16 <p>Enter your email address below and we'll send you password reset instructions.</p>
17
18 <div class="row">
19 {{ form_label(form.email) }}
20 {{ form_errors(form.email) }}
21 {{ form_widget(form.email) }}
22 </div>
23
24 <div class="row mts txtcenter">
25 <button type="submit">Send me reset instructions</button>
26 </div>
27 </fieldset>
28
29 {{ form_rest(form) }}
30 </form>
31{% endblock %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Security/login.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Security/login.html.twig
deleted file mode 100644
index 5437d20c..00000000
--- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Security/login.html.twig
+++ /dev/null
@@ -1,39 +0,0 @@
1{% extends "WallabagCoreBundle::layout.html.twig" %}
2
3{% block title %}{% trans %}login to your wallabag{% endtrans %}{% endblock %}
4
5{% block body_class %}login{% endblock %}
6
7{% block menu %}{% endblock %}
8{% block messages %}{% endblock %}
9
10{% block content %}
11 <form action="{{ path('login_check') }}" method="post" name="loginform">
12 <fieldset class="w500p center">
13 <h2 class="mbs txtcenter">{% trans %}Login to wallabag{% endtrans %}</h2>
14 {% if error %}
15 <div>{{ error.message }}</div>
16 {% endif %}
17
18 {% for flashMessage in app.session.flashbag.get('notice') %}
19 <p>{{ flashMessage }}</p>
20 {% endfor %}
21
22 <div class="row">
23 <label class="col w150p" for="username">{% trans %}Username{% endtrans %}</label>
24 <input type="text" id="username" name="_username" value="{{ last_username }}" />
25 </div>
26
27 <div class="row">
28 <label class="col w150p" for="password">{% trans %}Password{% endtrans %}</label>
29 <input type="password" id="password" name="_password" />
30 </div>
31
32 <div class="row mts txtcenter">
33 <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}" />
34 <button type="submit">Login</button>
35 <a href="{{ path('forgot_password') }}" class="small">Forgot your password?</a>
36 </div>
37 </fieldset>
38 </form>
39{% endblock %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Security/reset.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Security/reset.html.twig
deleted file mode 100644
index fda88af2..00000000
--- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Security/reset.html.twig
+++ /dev/null
@@ -1,35 +0,0 @@
1{% extends "WallabagCoreBundle::layout.html.twig" %}
2
3{% block title %}{% trans %}Change password{% endtrans %}{% endblock %}
4
5{% block body_class %}login{% endblock %}
6
7{% block menu %}{% endblock %}
8
9{% block content %}
10 <form action="{{ path('forgot_password_reset', {'token': token}) }}" method="post" name="loginform">
11 <fieldset class="w500p center">
12 <h2 class="mbs txtcenter">{% trans %}Change password{% endtrans %}</h2>
13
14 {{ form_errors(form) }}
15
16 <div class="row">
17 {{ form_label(form.new_password.first) }}
18 {{ form_errors(form.new_password.first) }}
19 {{ form_widget(form.new_password.first) }}
20 </div>
21
22 <div class="row">
23 {{ form_label(form.new_password.second) }}
24 {{ form_errors(form.new_password.second) }}
25 {{ form_widget(form.new_password.second) }}
26 </div>
27
28 <div class="row mts txtcenter">
29 <button type="submit">Change password</button>
30 </div>
31 </fieldset>
32
33 {{ form_rest(form) }}
34 </form>
35{% endblock %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig
index 3d573eaa..de4ed2e7 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig
@@ -52,7 +52,7 @@
52 </li> 52 </li>
53 <li><a href="{{ path('config') }}">{% trans %}config{% endtrans %}</a></li> 53 <li><a href="{{ path('config') }}">{% trans %}config{% endtrans %}</a></li>
54 <li><a href="{{ path('about') }}">{% trans %}about{% endtrans %}</a></li> 54 <li><a href="{{ path('about') }}">{% trans %}about{% endtrans %}</a></li>
55 <li><a class="icon icon-power" href="{{ path('logout') }}" title="{% trans %}logout{% endtrans %}">{% trans %}logout{% endtrans %}</a></li> 55 <li><a class="icon icon-power" href="{{ path('fos_user_security_logout') }}" title="{% trans %}logout{% endtrans %}">{% trans %}logout{% endtrans %}</a></li>
56 </ul> 56 </ul>
57{% endblock %} 57{% endblock %}
58 58
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig
index 0ff21f22..0d8e9f24 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig
@@ -15,7 +15,9 @@
15 <li class="tab col s3"><a href="#set2">{% trans %}RSS{% endtrans %}</a></li> 15 <li class="tab col s3"><a href="#set2">{% trans %}RSS{% endtrans %}</a></li>
16 <li class="tab col s3"><a href="#set3">{% trans %}User information{% endtrans %}</a></li> 16 <li class="tab col s3"><a href="#set3">{% trans %}User information{% endtrans %}</a></li>
17 <li class="tab col s3"><a href="#set4">{% trans %}Password{% endtrans %}</a></li> 17 <li class="tab col s3"><a href="#set4">{% trans %}Password{% endtrans %}</a></li>
18 {% if is_granted('ROLE_SUPER_ADMIN') %}
18 <li class="tab col s3"><a href="#set5">{% trans %}Add a user{% endtrans %}</a></li> 19 <li class="tab col s3"><a href="#set5">{% trans %}Add a user{% endtrans %}</a></li>
20 {% endif %}
19 </ul> 21 </ul>
20 </div> 22 </div>
21 23
@@ -175,7 +177,7 @@
175 </form> 177 </form>
176 </div> 178 </div>
177 179
178 180 {% if is_granted('ROLE_SUPER_ADMIN') %}
179 <div id="set5" class="col s12"> 181 <div id="set5" class="col s12">
180 <form action="{{ path('config') }}#set5" method="post" {{ form_enctype(form.new_user) }}> 182 <form action="{{ path('config') }}#set5" method="post" {{ form_enctype(form.new_user) }}>
181 {{ form_errors(form.new_user) }} 183 {{ form_errors(form.new_user) }}
@@ -190,9 +192,17 @@
190 192
191 <div class="row"> 193 <div class="row">
192 <div class="input-field col s12"> 194 <div class="input-field col s12">
193 {{ form_label(form.new_user.password) }} 195 {{ form_label(form.new_user.plainPassword.first) }}
194 {{ form_errors(form.new_user.password) }} 196 {{ form_errors(form.new_user.plainPassword.first) }}
195 {{ form_widget(form.new_user.password) }} 197 {{ form_widget(form.new_user.plainPassword.first) }}
198 </div>
199 </div>
200
201 <div class="row">
202 <div class="input-field col s12">
203 {{ form_label(form.new_user.plainPassword.second) }}
204 {{ form_errors(form.new_user.plainPassword.second) }}
205 {{ form_widget(form.new_user.plainPassword.second) }}
196 </div> 206 </div>
197 </div> 207 </div>
198 208
@@ -211,6 +221,7 @@
211 221
212 </form> 222 </form>
213 </div> 223 </div>
224 {% endif %}
214 </div> 225 </div>
215 226
216 </div> 227 </div>
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 4eb6d2b8..b0da42ce 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
@@ -49,11 +49,12 @@
49 {% trans %}Login{% endtrans %} 49 {% trans %}Login{% endtrans %}
50 <i class="mdi-content-send right"></i> 50 <i class="mdi-content-send right"></i>
51 </button> 51 </button>
52 <a href="{{ path('fos_user_registration_register') }}">{% trans %}Register{% endtrans %}</a>
52 </div> 53 </div>
53 </form> 54 </form>
54 </div> 55 </div>
55 <div class="center"> 56 <div class="center">
56 <a href="{{ path('forgot_password') }}">{% trans %}Forgot your password?{% endtrans %}</a> 57 <a href="{{ path('fos_user_resetting_request') }}">{% trans %}Forgot your password?{% endtrans %}</a>
57 </div> 58 </div>
58 </div> 59 </div>
59 </main> 60 </main>
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
index 10dede8a..36e276f9 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
@@ -46,8 +46,7 @@
46 <li class="bold border-bottom {% if currentRoute == 'tags' %}active{% endif %}"><a class="waves-effect" href="{{ path('tag') }}">{% trans %}tags{% endtrans %}</a></li> 46 <li class="bold border-bottom {% if currentRoute == 'tags' %}active{% endif %}"><a class="waves-effect" href="{{ path('tag') }}">{% trans %}tags{% endtrans %}</a></li>
47 <li class="bold {% if currentRoute == 'config' %}active{% endif %}"><a class="waves-effect" href="{{ path('config') }}">{% trans %}config{% endtrans %}</a></li> 47 <li class="bold {% if currentRoute == 'config' %}active{% endif %}"><a class="waves-effect" href="{{ path('config') }}">{% trans %}config{% endtrans %}</a></li>
48 <li class="bold {% if currentRoute == 'howto' %}active{% endif %}"><a class="waves-effect" href="{{ path('howto') }}">{% trans %}howto{% endtrans %}</a></li> 48 <li class="bold {% if currentRoute == 'howto' %}active{% endif %}"><a class="waves-effect" href="{{ path('howto') }}">{% trans %}howto{% endtrans %}</a></li>
49 <li class="bold border-bottom {% if currentRoute == 'about' %}active{% endif %}"><a class="waves-effect" href="{{ path('about') }}">{% trans %}About{% endtrans %}</a></li> 49 <li class="bold"><a class="waves-effect" class="icon icon-power" href="{{ path('fos_user_security_logout') }}" title="{% trans %}logout{% endtrans %}">{% trans %}logout{% endtrans %}</a></li>
50 <li class="bold"><a class="waves-effect" class="icon icon-power" href="{{ path('logout') }}" title="{% trans %}logout{% endtrans %}">{% trans %}logout{% endtrans %}</a></li>
51 </ul> 50 </ul>
52 <div class="nav-wrapper nav-panels"> 51 <div class="nav-wrapper nav-panels">
53 <a href="#" data-activates="slide-out" class="nav-panel-menu button-collapse"><i class="mdi-navigation-menu"></i></a> 52 <a href="#" data-activates="slide-out" class="nav-panel-menu button-collapse"><i class="mdi-navigation-menu"></i></a>
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/public/css/main.css b/src/Wallabag/CoreBundle/Resources/views/themes/material/public/css/main.css
index a5742905..1fe4a533 100755
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/public/css/main.css
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/public/css/main.css
@@ -24,6 +24,10 @@ body {
24 background: #f0f0f0; 24 background: #f0f0f0;
25} 25}
26 26
27body.login main {
28 padding: 0;
29}
30
27#warning_message { 31#warning_message {
28 position: fixed; 32 position: fixed;
29 background-color: #ff6347; 33 background-color: #ff6347;
@@ -250,9 +254,14 @@ main ul.row {
250} 254}
251 255
252.card .card-action a { 256.card .card-action a {
257 color: #ffffff;
253 margin: 0; 258 margin: 0;
254} 259}
255 260
261.card .card-action a:hover {
262 color: #ffffff;
263}
264
256.settings .div_tabs { 265.settings .div_tabs {
257 padding-bottom: 15px; 266 padding-bottom: 15px;
258} 267}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/public/img/logo-other_themes.png b/src/Wallabag/CoreBundle/Resources/views/themes/material/public/img/logo-other_themes.png
index 32543a44..c90aa46f 100755
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/public/img/logo-other_themes.png
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/public/img/logo-other_themes.png
Binary files differ
diff --git a/src/Wallabag/CoreBundle/Security/Authentication/Encoder/WallabagPasswordEncoder.php b/src/Wallabag/CoreBundle/Security/Authentication/Encoder/WallabagPasswordEncoder.php
deleted file mode 100644
index 98b4e86b..00000000
--- a/src/Wallabag/CoreBundle/Security/Authentication/Encoder/WallabagPasswordEncoder.php
+++ /dev/null
@@ -1,87 +0,0 @@
1<?php
2
3namespace Wallabag\CoreBundle\Security\Authentication\Encoder;
4
5use Symfony\Component\Security\Core\Encoder\BasePasswordEncoder;
6use Symfony\Component\Security\Core\Exception\BadCredentialsException;
7
8/**
9 * This override just add en extra variable (username) to be able to salt the password
10 * the way Wallabag v1 does. It will avoid to break compatibility with Wallabag v1.
11 */
12class WallabagPasswordEncoder extends BasePasswordEncoder
13{
14 private $algorithm;
15 private $encodeHashAsBase64;
16 private $iterations;
17 private $username = null;
18
19 /**
20 * Constructor.
21 *
22 * @param string $algorithm The digest algorithm to use
23 * @param bool $encodeHashAsBase64 Whether to base64 encode the password hash
24 * @param int $iterations The number of iterations to use to stretch the password hash
25 */
26 public function __construct($algorithm = 'sha512', $encodeHashAsBase64 = true, $iterations = 5000)
27 {
28 $this->algorithm = $algorithm;
29 $this->encodeHashAsBase64 = $encodeHashAsBase64;
30 $this->iterations = $iterations;
31 }
32
33 public function setUsername($username)
34 {
35 $this->username = $username;
36 }
37
38 /**
39 * {@inheritdoc}
40 */
41 public function encodePassword($raw, $salt)
42 {
43 if ($this->isPasswordTooLong($raw)) {
44 throw new BadCredentialsException('Invalid password.');
45 }
46
47 if (!in_array($this->algorithm, hash_algos(), true)) {
48 throw new \LogicException(sprintf('The algorithm "%s" is not supported.', $this->algorithm));
49 }
50
51 $salted = $this->mergePasswordAndSalt($raw, $salt);
52 $digest = hash($this->algorithm, $salted, true);
53
54 // "stretch" hash
55 for ($i = 1; $i < $this->iterations; ++$i) {
56 $digest = hash($this->algorithm, $digest.$salted, true);
57 }
58
59 return $this->encodeHashAsBase64 ? base64_encode($digest) : bin2hex($digest);
60 }
61
62 /**
63 * {@inheritdoc}
64 *
65 * We inject the username inside the salted password
66 */
67 protected function mergePasswordAndSalt($password, $salt)
68 {
69 if (null === $this->username) {
70 throw new \LogicException('We can not check the password without a username.');
71 }
72
73 if (empty($salt)) {
74 return $password;
75 }
76
77 return $password.$this->username.$salt;
78 }
79
80 /**
81 * {@inheritdoc}
82 */
83 public function isPasswordValid($encoded, $raw, $salt)
84 {
85 return !$this->isPasswordTooLong($raw) && $this->comparePasswords($encoded, $this->encodePassword($raw, $salt));
86 }
87}
diff --git a/src/Wallabag/CoreBundle/Security/Authentication/Provider/WallabagAuthenticationProvider.php b/src/Wallabag/CoreBundle/Security/Authentication/Provider/WallabagAuthenticationProvider.php
deleted file mode 100644
index cf3cb051..00000000
--- a/src/Wallabag/CoreBundle/Security/Authentication/Provider/WallabagAuthenticationProvider.php
+++ /dev/null
@@ -1,89 +0,0 @@
1<?php
2
3namespace Wallabag\CoreBundle\Security\Authentication\Provider;
4
5use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
6use Symfony\Component\Security\Core\User\UserProviderInterface;
7use Symfony\Component\Security\Core\User\UserCheckerInterface;
8use Symfony\Component\Security\Core\User\UserInterface;
9use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
10use Symfony\Component\Security\Core\Exception\AuthenticationServiceException;
11use Symfony\Component\Security\Core\Exception\BadCredentialsException;
12use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
13use Symfony\Component\Security\Core\Authentication\Provider\UserAuthenticationProvider;
14
15class WallabagAuthenticationProvider extends UserAuthenticationProvider
16{
17 private $encoderFactory;
18 private $userProvider;
19
20 /**
21 * Constructor.
22 *
23 * @param UserProviderInterface $userProvider An UserProviderInterface instance
24 * @param UserCheckerInterface $userChecker An UserCheckerInterface instance
25 * @param string $providerKey The provider key
26 * @param EncoderFactoryInterface $encoderFactory An EncoderFactoryInterface instance
27 * @param bool $hideUserNotFoundExceptions Whether to hide user not found exception or not
28 */
29 public function __construct(UserProviderInterface $userProvider, UserCheckerInterface $userChecker, $providerKey, EncoderFactoryInterface $encoderFactory, $hideUserNotFoundExceptions = true)
30 {
31 parent::__construct($userChecker, $providerKey, $hideUserNotFoundExceptions);
32
33 $this->encoderFactory = $encoderFactory;
34 $this->userProvider = $userProvider;
35 }
36
37 /**
38 * {@inheritdoc}
39 */
40 protected function checkAuthentication(UserInterface $user, UsernamePasswordToken $token)
41 {
42 $currentUser = $token->getUser();
43 if ($currentUser instanceof UserInterface) {
44 if ($currentUser->getPassword() !== $user->getPassword()) {
45 throw new BadCredentialsException('The credentials were changed from another session.');
46 }
47 } else {
48 if ('' === ($presentedPassword = $token->getCredentials())) {
49 throw new BadCredentialsException('The presented password cannot be empty.');
50 }
51
52 // give username, it's used to hash the password
53 $encoder = $this->encoderFactory->getEncoder($user);
54 $encoder->setUsername($user->getUsername());
55
56 if (!$encoder->isPasswordValid($user->getPassword(), $presentedPassword, $user->getSalt())) {
57 throw new BadCredentialsException('The presented password is invalid.');
58 }
59 }
60 }
61
62 /**
63 * {@inheritdoc}
64 */
65 protected function retrieveUser($username, UsernamePasswordToken $token)
66 {
67 $user = $token->getUser();
68 if ($user instanceof UserInterface) {
69 return $user;
70 }
71
72 try {
73 $user = $this->userProvider->loadUserByUsername($username);
74
75 if (!$user instanceof UserInterface) {
76 throw new AuthenticationServiceException('The user provider must return a UserInterface object.');
77 }
78
79 return $user;
80 } catch (UsernameNotFoundException $notFound) {
81 $notFound->setUsername($username);
82 throw $notFound;
83 } catch (\Exception $repositoryProblem) {
84 $ex = new AuthenticationServiceException($repositoryProblem->getMessage(), 0, $repositoryProblem);
85 $ex->setToken($token);
86 throw $ex;
87 }
88 }
89}
diff --git a/src/Wallabag/CoreBundle/Security/Validator/WallabagUserPasswordValidator.php b/src/Wallabag/CoreBundle/Security/Validator/WallabagUserPasswordValidator.php
deleted file mode 100644
index 52062773..00000000
--- a/src/Wallabag/CoreBundle/Security/Validator/WallabagUserPasswordValidator.php
+++ /dev/null
@@ -1,51 +0,0 @@
1<?php
2
3namespace Wallabag\CoreBundle\Security\Validator;
4
5use Symfony\Component\Security\Core\User\UserInterface;
6use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
7use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
8use Symfony\Component\Validator\Constraint;
9use Symfony\Component\Validator\ConstraintValidator;
10use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
11use Symfony\Component\Validator\Exception\UnexpectedTypeException;
12use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
13
14/**
15 * @see Symfony\Component\Security\Core\Validator\Constraints\UserPasswordValidator
16 */
17class WallabagUserPasswordValidator extends ConstraintValidator
18{
19 private $securityContext;
20 private $encoderFactory;
21
22 public function __construct(TokenStorageInterface $tokenStorage, EncoderFactoryInterface $encoderFactory)
23 {
24 $this->tokenStorage = $tokenStorage;
25 $this->encoderFactory = $encoderFactory;
26 }
27
28 /**
29 * {@inheritdoc}
30 */
31 public function validate($password, Constraint $constraint)
32 {
33 if (!$constraint instanceof UserPassword) {
34 throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\UserPassword');
35 }
36
37 $user = $this->tokenStorage->getToken()->getUser();
38
39 if (!$user instanceof UserInterface) {
40 throw new ConstraintDefinitionException('The User object must implement the UserInterface interface.');
41 }
42
43 // give username, it's used to hash the password
44 $encoder = $this->encoderFactory->getEncoder($user);
45 $encoder->setUsername($user->getUsername());
46
47 if (!$encoder->isPasswordValid($user->getPassword(), $password, $user->getSalt())) {
48 $this->context->addViolation($constraint->message);
49 }
50 }
51}
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
index 3407fc5e..3da5e8b7 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
@@ -258,7 +258,8 @@ class ConfigControllerTest extends WallabagCoreTestCase
258 array( 258 array(
259 array( 259 array(
260 'new_user[username]' => '', 260 'new_user[username]' => '',
261 'new_user[password]' => '', 261 'new_user[plainPassword][first]' => '',
262 'new_user[plainPassword][second]' => '',
262 'new_user[email]' => '', 263 'new_user[email]' => '',
263 ), 264 ),
264 'Please enter a username', 265 'Please enter a username',
@@ -266,7 +267,8 @@ class ConfigControllerTest extends WallabagCoreTestCase
266 array( 267 array(
267 array( 268 array(
268 'new_user[username]' => 'a', 269 'new_user[username]' => 'a',
269 'new_user[password]' => 'mypassword', 270 'new_user[plainPassword][first]' => 'mypassword',
271 'new_user[plainPassword][second]' => 'mypassword',
270 'new_user[email]' => '', 272 'new_user[email]' => '',
271 ), 273 ),
272 'The username is too short', 274 'The username is too short',
@@ -274,7 +276,8 @@ class ConfigControllerTest extends WallabagCoreTestCase
274 array( 276 array(
275 array( 277 array(
276 'new_user[username]' => 'wallace', 278 'new_user[username]' => 'wallace',
277 'new_user[password]' => 'mypassword', 279 'new_user[plainPassword][first]' => 'mypassword',
280 'new_user[plainPassword][second]' => 'mypassword',
278 'new_user[email]' => 'test', 281 'new_user[email]' => 'test',
279 ), 282 ),
280 'The email is not valid', 283 'The email is not valid',
@@ -282,11 +285,21 @@ class ConfigControllerTest extends WallabagCoreTestCase
282 array( 285 array(
283 array( 286 array(
284 'new_user[username]' => 'admin', 287 'new_user[username]' => 'admin',
285 'new_user[password]' => 'wallacewallace', 288 'new_user[plainPassword][first]' => 'wallacewallace',
289 'new_user[plainPassword][second]' => 'wallacewallace',
286 'new_user[email]' => 'wallace@wallace.me', 290 'new_user[email]' => 'wallace@wallace.me',
287 ), 291 ),
288 'The username is already used', 292 'The username is already used',
289 ), 293 ),
294 array(
295 array(
296 'new_user[username]' => 'wallace',
297 'new_user[plainPassword][first]' => 'mypassword1',
298 'new_user[plainPassword][second]' => 'mypassword2',
299 'new_user[email]' => 'wallace@wallace.me',
300 ),
301 'This value is not valid',
302 ),
290 ); 303 );
291 } 304 }
292 305
@@ -325,7 +338,8 @@ class ConfigControllerTest extends WallabagCoreTestCase
325 338
326 $data = array( 339 $data = array(
327 'new_user[username]' => 'wallace', 340 'new_user[username]' => 'wallace',
328 'new_user[password]' => 'wallace1', 341 'new_user[plainPassword][first]' => 'wallace1',
342 'new_user[plainPassword][second]' => 'wallace1',
329 'new_user[email]' => 'wallace@wallace.me', 343 'new_user[email]' => 'wallace@wallace.me',
330 ); 344 );
331 345
@@ -340,7 +354,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
340 354
341 $em = $client->getContainer()->get('doctrine.orm.entity_manager'); 355 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
342 $user = $em 356 $user = $em
343 ->getRepository('WallabagCoreBundle:User') 357 ->getRepository('WallabagUserBundle:User')
344 ->findOneByUsername('wallace'); 358 ->findOneByUsername('wallace');
345 359
346 $this->assertTrue(false !== $user); 360 $this->assertTrue(false !== $user);
@@ -355,7 +369,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
355 // reset the token 369 // reset the token
356 $em = $client->getContainer()->get('doctrine.orm.entity_manager'); 370 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
357 $user = $em 371 $user = $em
358 ->getRepository('WallabagCoreBundle:User') 372 ->getRepository('WallabagUserBundle:User')
359 ->findOneByUsername('admin'); 373 ->findOneByUsername('admin');
360 374
361 if (!$user) { 375 if (!$user) {
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/RssControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/RssControllerTest.php
index b7c162a7..45a74c43 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/RssControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/RssControllerTest.php
@@ -64,7 +64,7 @@ class RssControllerTest extends WallabagCoreTestCase
64 $client = $this->getClient(); 64 $client = $this->getClient();
65 $em = $client->getContainer()->get('doctrine.orm.entity_manager'); 65 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
66 $user = $em 66 $user = $em
67 ->getRepository('WallabagCoreBundle:User') 67 ->getRepository('WallabagUserBundle:User')
68 ->findOneByUsername('admin'); 68 ->findOneByUsername('admin');
69 69
70 $config = $user->getConfig(); 70 $config = $user->getConfig();
@@ -85,7 +85,7 @@ class RssControllerTest extends WallabagCoreTestCase
85 $client = $this->getClient(); 85 $client = $this->getClient();
86 $em = $client->getContainer()->get('doctrine.orm.entity_manager'); 86 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
87 $user = $em 87 $user = $em
88 ->getRepository('WallabagCoreBundle:User') 88 ->getRepository('WallabagUserBundle:User')
89 ->findOneByUsername('admin'); 89 ->findOneByUsername('admin');
90 90
91 $config = $user->getConfig(); 91 $config = $user->getConfig();
@@ -107,7 +107,7 @@ class RssControllerTest extends WallabagCoreTestCase
107 $client = $this->getClient(); 107 $client = $this->getClient();
108 $em = $client->getContainer()->get('doctrine.orm.entity_manager'); 108 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
109 $user = $em 109 $user = $em
110 ->getRepository('WallabagCoreBundle:User') 110 ->getRepository('WallabagUserBundle:User')
111 ->findOneByUsername('admin'); 111 ->findOneByUsername('admin');
112 112
113 $config = $user->getConfig(); 113 $config = $user->getConfig();
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php
deleted file mode 100644
index 759ef01b..00000000
--- a/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php
+++ /dev/null
@@ -1,201 +0,0 @@
1<?php
2
3namespace Wallabag\CoreBundle\Tests\Controller;
4
5use Symfony\Component\Filesystem\Filesystem;
6use Symfony\Component\Finder\Finder;
7use Wallabag\CoreBundle\Tests\WallabagCoreTestCase;
8
9class SecurityControllerTest extends WallabagCoreTestCase
10{
11 public function testLogin()
12 {
13 $client = $this->getClient();
14
15 $crawler = $client->request('GET', '/new');
16
17 $this->assertEquals(302, $client->getResponse()->getStatusCode());
18 $this->assertContains('login', $client->getResponse()->headers->get('location'));
19 }
20
21 public function testLoginFail()
22 {
23 $client = $this->getClient();
24
25 $crawler = $client->request('GET', '/login');
26
27 $form = $crawler->filter('button[type=submit]')->form();
28 $data = array(
29 '_username' => 'admin',
30 '_password' => 'admin',
31 );
32
33 $client->submit($form, $data);
34
35 $this->assertEquals(302, $client->getResponse()->getStatusCode());
36 $this->assertContains('login', $client->getResponse()->headers->get('location'));
37
38 $crawler = $client->followRedirect();
39
40 $this->assertContains('Bad credentials', $client->getResponse()->getContent());
41 }
42
43 public function testRedirectionAfterLogin()
44 {
45 $client = $this->getClient();
46 $client->followRedirects();
47
48 $crawler = $client->request('GET', '/config');
49
50 $form = $crawler->filter('button[type=submit]')->form();
51
52 $data = array(
53 '_username' => 'admin',
54 '_password' => 'mypassword',
55 );
56
57 $client->submit($form, $data);
58
59 $this->assertContains('RSS', $client->getResponse()->getContent());
60 }
61
62 public function testForgotPassword()
63 {
64 $client = $this->getClient();
65
66 $crawler = $client->request('GET', '/forgot-password');
67
68 $this->assertEquals(200, $client->getResponse()->getStatusCode());
69
70 $this->assertContains('Forgot password', $client->getResponse()->getContent());
71
72 $form = $crawler->filter('button[type=submit]');
73
74 $this->assertCount(1, $form);
75
76 return array(
77 'form' => $form->form(),
78 'client' => $client,
79 );
80 }
81
82 /**
83 * @depends testForgotPassword
84 */
85 public function testSubmitForgotPasswordFail($parameters)
86 {
87 $form = $parameters['form'];
88 $client = $parameters['client'];
89
90 $data = array(
91 'forgot_password[email]' => 'material',
92 );
93
94 $client->submit($form, $data);
95
96 $this->assertEquals(200, $client->getResponse()->getStatusCode());
97 $this->assertContains('No user found with this email', $client->getResponse()->getContent());
98 }
99
100 /**
101 * @depends testForgotPassword
102 *
103 * Instead of using collector which slow down the test suite
104 * http://symfony.com/doc/current/cookbook/email/testing.html
105 *
106 * Use a different way where Swift store email as file
107 */
108 public function testSubmitForgotPassword($parameters)
109 {
110 $form = $parameters['form'];
111 $client = $parameters['client'];
112
113 $spoolDir = $client->getKernel()->getContainer()->getParameter('swiftmailer.spool.default.file.path');
114
115 // cleanup pool dir
116 $filesystem = new Filesystem();
117 $filesystem->remove($spoolDir);
118
119 // to use `getCollector` since `collect: false` in config_test.yml
120 $client->enableProfiler();
121
122 $data = array(
123 'forgot_password[email]' => 'bobby@wallabag.org',
124 );
125
126 $client->submit($form, $data);
127
128 $this->assertEquals(302, $client->getResponse()->getStatusCode());
129
130 $crawler = $client->followRedirect();
131
132 $this->assertContains('An email has been sent to', $client->getResponse()->getContent());
133
134 // find every files (ie: emails) inside the spool dir except hidden files
135 $finder = new Finder();
136 $finder
137 ->in($spoolDir)
138 ->ignoreDotFiles(true)
139 ->files();
140
141 $this->assertCount(1, $finder, 'Only one email has been sent');
142
143 foreach ($finder as $file) {
144 $message = unserialize(file_get_contents($file));
145
146 $this->assertInstanceOf('Swift_Message', $message);
147 $this->assertEquals('Reset Password', $message->getSubject());
148 $this->assertEquals('no-reply@wallabag.org', key($message->getFrom()));
149 $this->assertEquals('bobby@wallabag.org', key($message->getTo()));
150 $this->assertContains(
151 'To reset your password - please visit',
152 $message->getBody()
153 );
154 }
155 }
156
157 public function testReset()
158 {
159 $client = $this->getClient();
160 $user = $client->getContainer()
161 ->get('doctrine.orm.entity_manager')
162 ->getRepository('WallabagCoreBundle:User')
163 ->findOneByEmail('bobby@wallabag.org');
164
165 $crawler = $client->request('GET', '/forgot-password/'.$user->getConfirmationToken());
166
167 $this->assertEquals(200, $client->getResponse()->getStatusCode());
168 $this->assertCount(2, $crawler->filter('input[type=password]'));
169 $this->assertCount(1, $form = $crawler->filter('button[type=submit]'));
170 $this->assertCount(1, $form);
171
172 $data = array(
173 'change_passwd[new_password][first]' => 'mypassword',
174 'change_passwd[new_password][second]' => 'mypassword',
175 );
176
177 $client->submit($form->form(), $data);
178
179 $this->assertEquals(302, $client->getResponse()->getStatusCode());
180 $this->assertContains('login', $client->getResponse()->headers->get('location'));
181 }
182
183 public function testResetBadToken()
184 {
185 $client = $this->getClient();
186
187 $client->request('GET', '/forgot-password/UIZOAU29UE902IEPZO');
188
189 $this->assertEquals(404, $client->getResponse()->getStatusCode());
190 }
191
192 public function testCheckEmailWithoutEmail()
193 {
194 $client = $this->getClient();
195
196 $client->request('GET', '/forgot-password/check-email');
197
198 $this->assertEquals(302, $client->getResponse()->getStatusCode());
199 $this->assertContains('forgot-password', $client->getResponse()->headers->get('location'));
200 }
201}
diff --git a/src/Wallabag/CoreBundle/Tests/EventListener/RegistrationConfirmedListenerTest.php b/src/Wallabag/CoreBundle/Tests/EventListener/RegistrationConfirmedListenerTest.php
new file mode 100644
index 00000000..df94fad2
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Tests/EventListener/RegistrationConfirmedListenerTest.php
@@ -0,0 +1,92 @@
1<?php
2
3namespace Wallabag\CoreBundle\Tests\EventListener;
4
5use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
6use Symfony\Component\EventDispatcher\EventDispatcher;
7use Symfony\Component\HttpFoundation\Request;
8use Symfony\Component\HttpFoundation\Response;
9use FOS\UserBundle\FOSUserEvents;
10use FOS\UserBundle\Event\FilterUserResponseEvent;
11use Wallabag\CoreBundle\EventListener\RegistrationConfirmedListener;
12use Wallabag\CoreBundle\Entity\Config;
13use Wallabag\UserBundle\Entity\User;
14
15class RegistrationConfirmedListenerTest extends KernelTestCase
16{
17 private $em;
18 private $listener;
19 private $dispatcher;
20 private $request;
21 private $response;
22
23 protected function setUp()
24 {
25 $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
26 ->disableOriginalConstructor()
27 ->getMock();
28
29 $this->listener = new RegistrationConfirmedListener(
30 $this->em,
31 'baggy',
32 20,
33 50,
34 'fr'
35 );
36
37 $this->dispatcher = new EventDispatcher();
38 $this->dispatcher->addSubscriber($this->listener);
39
40 $this->request = Request::create('/');
41 $this->response = Response::create();
42 }
43
44 public function testWithInvalidUser()
45 {
46 $user = new User();
47 $user->setEnabled(false);
48
49 $event = new FilterUserResponseEvent(
50 $user,
51 $this->request,
52 $this->response
53 );
54
55 $this->em->expects($this->never())->method('persist');
56 $this->em->expects($this->never())->method('flush');
57
58 $this->dispatcher->dispatch(
59 FOSUserEvents::REGISTRATION_CONFIRMED,
60 $event
61 );
62 }
63
64 public function testWithValidUser()
65 {
66 $user = new User();
67 $user->setEnabled(true);
68
69 $event = new FilterUserResponseEvent(
70 $user,
71 $this->request,
72 $this->response
73 );
74
75 $config = new Config($user);
76 $config->setTheme('baggy');
77 $config->setItemsPerPage(20);
78 $config->setRssLimit(50);
79 $config->setLanguage('fr');
80
81 $this->em->expects($this->once())
82 ->method('persist')
83 ->will($this->returnValue($config));
84 $this->em->expects($this->once())
85 ->method('flush');
86
87 $this->dispatcher->dispatch(
88 FOSUserEvents::REGISTRATION_CONFIRMED,
89 $event
90 );
91 }
92}
diff --git a/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php b/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php
index 0d338389..1d0d4062 100644
--- a/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php
@@ -4,7 +4,7 @@ namespace Wallabag\CoreBundle\Tests\Helper;
4 4
5use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; 5use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
6use Wallabag\CoreBundle\Entity\Entry; 6use Wallabag\CoreBundle\Entity\Entry;
7use Wallabag\CoreBundle\Entity\User; 7use Wallabag\UserBundle\Entity\User;
8use Wallabag\CoreBundle\Helper\ContentProxy; 8use Wallabag\CoreBundle\Helper\ContentProxy;
9 9
10class ContentProxyTest extends KernelTestCase 10class ContentProxyTest extends KernelTestCase
diff --git a/src/Wallabag/CoreBundle/Tests/ParamConverter/UsernameRssTokenConverterTest.php b/src/Wallabag/CoreBundle/Tests/ParamConverter/UsernameRssTokenConverterTest.php
index ebb550b5..e28dc4ba 100644
--- a/src/Wallabag/CoreBundle/Tests/ParamConverter/UsernameRssTokenConverterTest.php
+++ b/src/Wallabag/CoreBundle/Tests/ParamConverter/UsernameRssTokenConverterTest.php
@@ -6,7 +6,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
6use Wallabag\CoreBundle\ParamConverter\UsernameRssTokenConverter; 6use Wallabag\CoreBundle\ParamConverter\UsernameRssTokenConverter;
7use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; 7use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
8use Symfony\Component\HttpFoundation\Request; 8use Symfony\Component\HttpFoundation\Request;
9use Wallabag\CoreBundle\Entity\User; 9use Wallabag\UserBundle\Entity\User;
10 10
11class UsernameRssTokenConverterTest extends KernelTestCase 11class UsernameRssTokenConverterTest extends KernelTestCase
12{ 12{
@@ -96,7 +96,7 @@ class UsernameRssTokenConverterTest extends KernelTestCase
96 96
97 $meta->expects($this->once()) 97 $meta->expects($this->once())
98 ->method('getName') 98 ->method('getName')
99 ->will($this->returnValue('Wallabag\CoreBundle\Entity\User')); 99 ->will($this->returnValue('Wallabag\UserBundle\Entity\User'));
100 100
101 $em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager') 101 $em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')
102 ->disableOriginalConstructor() 102 ->disableOriginalConstructor()
@@ -104,7 +104,7 @@ class UsernameRssTokenConverterTest extends KernelTestCase
104 104
105 $em->expects($this->once()) 105 $em->expects($this->once())
106 ->method('getClassMetadata') 106 ->method('getClassMetadata')
107 ->with('WallabagCoreBundle:User') 107 ->with('WallabagUserBundle:User')
108 ->will($this->returnValue($meta)); 108 ->will($this->returnValue($meta));
109 109
110 $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry') 110 $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')
@@ -117,10 +117,10 @@ class UsernameRssTokenConverterTest extends KernelTestCase
117 117
118 $registry->expects($this->once()) 118 $registry->expects($this->once())
119 ->method('getManagerForClass') 119 ->method('getManagerForClass')
120 ->with('WallabagCoreBundle:User') 120 ->with('WallabagUserBundle:User')
121 ->will($this->returnValue($em)); 121 ->will($this->returnValue($em));
122 122
123 $params = new ParamConverter(array('class' => 'WallabagCoreBundle:User')); 123 $params = new ParamConverter(array('class' => 'WallabagUserBundle:User'));
124 $converter = new UsernameRssTokenConverter($registry); 124 $converter = new UsernameRssTokenConverter($registry);
125 125
126 $this->assertTrue($converter->supports($params)); 126 $this->assertTrue($converter->supports($params));
@@ -144,7 +144,7 @@ class UsernameRssTokenConverterTest extends KernelTestCase
144 */ 144 */
145 public function testApplyUserNotFound() 145 public function testApplyUserNotFound()
146 { 146 {
147 $repo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\UserRepository') 147 $repo = $this->getMockBuilder('Wallabag\UserBundle\Repository\UserRepository')
148 ->disableOriginalConstructor() 148 ->disableOriginalConstructor()
149 ->getMock(); 149 ->getMock();
150 150
@@ -159,7 +159,7 @@ class UsernameRssTokenConverterTest extends KernelTestCase
159 159
160 $em->expects($this->once()) 160 $em->expects($this->once())
161 ->method('getRepository') 161 ->method('getRepository')
162 ->with('WallabagCoreBundle:User') 162 ->with('WallabagUserBundle:User')
163 ->will($this->returnValue($repo)); 163 ->will($this->returnValue($repo));
164 164
165 $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry') 165 $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')
@@ -168,10 +168,10 @@ class UsernameRssTokenConverterTest extends KernelTestCase
168 168
169 $registry->expects($this->once()) 169 $registry->expects($this->once())
170 ->method('getManagerForClass') 170 ->method('getManagerForClass')
171 ->with('WallabagCoreBundle:User') 171 ->with('WallabagUserBundle:User')
172 ->will($this->returnValue($em)); 172 ->will($this->returnValue($em));
173 173
174 $params = new ParamConverter(array('class' => 'WallabagCoreBundle:User')); 174 $params = new ParamConverter(array('class' => 'WallabagUserBundle:User'));
175 $converter = new UsernameRssTokenConverter($registry); 175 $converter = new UsernameRssTokenConverter($registry);
176 $request = new Request(array(), array(), array('username' => 'test', 'token' => 'test')); 176 $request = new Request(array(), array(), array('username' => 'test', 'token' => 'test'));
177 177
@@ -182,7 +182,7 @@ class UsernameRssTokenConverterTest extends KernelTestCase
182 { 182 {
183 $user = new User(); 183 $user = new User();
184 184
185 $repo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\UserRepository') 185 $repo = $this->getMockBuilder('Wallabag\UserBundle\Repository\UserRepository')
186 ->disableOriginalConstructor() 186 ->disableOriginalConstructor()
187 ->getMock(); 187 ->getMock();
188 188
@@ -197,7 +197,7 @@ class UsernameRssTokenConverterTest extends KernelTestCase
197 197
198 $em->expects($this->once()) 198 $em->expects($this->once())
199 ->method('getRepository') 199 ->method('getRepository')
200 ->with('WallabagCoreBundle:User') 200 ->with('WallabagUserBundle:User')
201 ->will($this->returnValue($repo)); 201 ->will($this->returnValue($repo));
202 202
203 $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry') 203 $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')
@@ -206,10 +206,10 @@ class UsernameRssTokenConverterTest extends KernelTestCase
206 206
207 $registry->expects($this->once()) 207 $registry->expects($this->once())
208 ->method('getManagerForClass') 208 ->method('getManagerForClass')
209 ->with('WallabagCoreBundle:User') 209 ->with('WallabagUserBundle:User')
210 ->will($this->returnValue($em)); 210 ->will($this->returnValue($em));
211 211
212 $params = new ParamConverter(array('class' => 'WallabagCoreBundle:User', 'name' => 'user')); 212 $params = new ParamConverter(array('class' => 'WallabagUserBundle:User', 'name' => 'user'));
213 $converter = new UsernameRssTokenConverter($registry); 213 $converter = new UsernameRssTokenConverter($registry);
214 $request = new Request(array(), array(), array('username' => 'test', 'token' => 'test')); 214 $request = new Request(array(), array(), array('username' => 'test', 'token' => 'test'));
215 215