aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--app/AppKernel.php1
-rw-r--r--app/config/config.yml2
-rw-r--r--app/config/routing.yml23
-rw-r--r--app/config/security.yml4
-rw-r--r--config/deploy.rb4
-rw-r--r--config/deploy/staging.rb2
-rw-r--r--src/Wallabag/ApiBundle/Entity/AccessToken.php2
-rw-r--r--src/Wallabag/ApiBundle/Entity/AuthCode.php2
-rw-r--r--src/Wallabag/ApiBundle/Entity/RefreshToken.php2
-rw-r--r--src/Wallabag/CoreBundle/Command/InstallCommand.php2
-rw-r--r--src/Wallabag/CoreBundle/Controller/ConfigController.php2
-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.php4
-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.php2
-rw-r--r--src/Wallabag/CoreBundle/Filter/EntryFilterType.php2
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/ForgotPasswordType.php2
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/NewUserType.php2
-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/Resources/views/themes/baggy/layout.html.twig2
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Security/login.html.twig2
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig3
-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.php4
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/RssControllerTest.php6
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php319
-rw-r--r--src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php2
-rw-r--r--src/Wallabag/CoreBundle/Tests/ParamConverter/UsernameRssTokenConverterTest.php26
-rw-r--r--src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php2
-rw-r--r--src/Wallabag/UserBundle/Entity/User.php (renamed from src/Wallabag/CoreBundle/Entity/User.php)19
-rw-r--r--src/Wallabag/UserBundle/Repository/UserRepository.php (renamed from src/Wallabag/CoreBundle/Repository/UserRepository.php)2
-rw-r--r--src/Wallabag/UserBundle/Resources/config/services.yml0
-rw-r--r--src/Wallabag/UserBundle/Resources/views/Default/index.html.twig1
-rw-r--r--src/Wallabag/UserBundle/WallabagUserBundle.php9
40 files changed, 93 insertions, 773 deletions
diff --git a/app/AppKernel.php b/app/AppKernel.php
index 6f8c3a6d..6315fcde 100644
--- a/app/AppKernel.php
+++ b/app/AppKernel.php
@@ -27,6 +27,7 @@ class AppKernel extends Kernel
27 new Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle(), 27 new Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle(),
28 new Lexik\Bundle\FormFilterBundle\LexikFormFilterBundle(), 28 new Lexik\Bundle\FormFilterBundle\LexikFormFilterBundle(),
29 new FOS\OAuthServerBundle\FOSOAuthServerBundle(), 29 new FOS\OAuthServerBundle\FOSOAuthServerBundle(),
30 new Wallabag\UserBundle\WallabagUserBundle(),
30 ); 31 );
31 32
32 if (in_array($this->getEnvironment(), array('dev', 'test'))) { 33 if (in_array($this->getEnvironment(), array('dev', 'test'))) {
diff --git a/app/config/config.yml b/app/config/config.yml
index 3c63ded3..a4d18c6d 100644
--- a/app/config/config.yml
+++ b/app/config/config.yml
@@ -158,7 +158,7 @@ liip_theme:
158fos_user: 158fos_user:
159 db_driver: orm 159 db_driver: orm
160 firewall_name: main 160 firewall_name: main
161 user_class: Wallabag\CoreBundle\Entity\User 161 user_class: Wallabag\UserBundle\Entity\User
162 registration: 162 registration:
163 form: 163 form:
164 type: wallabag_user_registration 164 type: wallabag_user_registration
diff --git a/app/config/routing.yml b/app/config/routing.yml
index dabb48fa..5fa28fba 100644
--- a/app/config/routing.yml
+++ b/app/config/routing.yml
@@ -1,3 +1,8 @@
1wallabag_user:
2 resource: "@WallabagUserBundle/Controller/"
3 type: annotation
4 prefix: /
5
1wallabag_api: 6wallabag_api:
2 resource: "@WallabagApiBundle/Resources/config/routing.yml" 7 resource: "@WallabagApiBundle/Resources/config/routing.yml"
3 prefix: / 8 prefix: /
@@ -10,15 +15,15 @@ doc-api:
10 resource: "@NelmioApiDocBundle/Resources/config/routing.yml" 15 resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
11 prefix: /api/doc 16 prefix: /api/doc
12 17
13login: 18#login:
14 pattern: /login 19# pattern: /login
15 defaults: { _controller: WallabagCoreBundle:Security:login } 20# defaults: { _controller: WallabagCoreBundle:Security:login }
16 21#
17login_check: 22#login_check:
18 pattern: /login_check 23# pattern: /login_check
19 24#
20logout: 25#logout:
21 path: /logout 26# path: /logout
22 27
23rest : 28rest :
24 type : rest 29 type : rest
diff --git a/app/config/security.yml b/app/config/security.yml
index 79a07c48..d7d8c12b 100644
--- a/app/config/security.yml
+++ b/app/config/security.yml
@@ -8,7 +8,7 @@ security:
8 8
9 providers: 9 providers:
10 administrators: 10 administrators:
11 entity: { class: WallabagCoreBundle:User, property: username } 11 entity: { class: WallabagUserBundle:User, property: username }
12 fos_userbundle: 12 fos_userbundle:
13 id: fos_user.user_provider.username 13 id: fos_user.user_provider.username
14 14
@@ -49,6 +49,6 @@ security:
49 - { path: ^/api/doc, roles: IS_AUTHENTICATED_ANONYMOUSLY } 49 - { path: ^/api/doc, roles: IS_AUTHENTICATED_ANONYMOUSLY }
50 - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } 50 - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
51 - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY } 51 - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
52 - { path: ^/forgot-password, roles: IS_AUTHENTICATED_ANONYMOUSLY } 52 - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
53 - { path: /(unread|starred|archive).xml$, roles: IS_AUTHENTICATED_ANONYMOUSLY } 53 - { path: /(unread|starred|archive).xml$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
54 - { path: ^/, roles: ROLE_USER } 54 - { path: ^/, roles: ROLE_USER }
diff --git a/config/deploy.rb b/config/deploy.rb
index be18ce5a..c2562965 100644
--- a/config/deploy.rb
+++ b/config/deploy.rb
@@ -4,8 +4,8 @@ lock '3.4.0'
4set :application, 'wallabag' 4set :application, 'wallabag'
5set :repo_url, 'git@github.com:wallabag/wallabag.git' 5set :repo_url, 'git@github.com:wallabag/wallabag.git'
6 6
7set :ssh_user, 'ssh_user' 7set :ssh_user, 'framasoft_bag'
8server 'server_ip', user: fetch(:ssh_user), roles: %w{web app db} 8server '78.46.248.87', user: fetch(:ssh_user), roles: %w{web app db}
9 9
10set :scm, :git 10set :scm, :git
11 11
diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb
index d67d7247..ccd05b4d 100644
--- a/config/deploy/staging.rb
+++ b/config/deploy/staging.rb
@@ -1,2 +1,2 @@
1set :branch, 'v2' 1set :branch, 'v2'
2set :deploy_to, '/var/www/' 2set :deploy_to, '/var/www/v2.wallabag.org/web/'
diff --git a/src/Wallabag/ApiBundle/Entity/AccessToken.php b/src/Wallabag/ApiBundle/Entity/AccessToken.php
index d6cf0af5..b1f4e7de 100644
--- a/src/Wallabag/ApiBundle/Entity/AccessToken.php
+++ b/src/Wallabag/ApiBundle/Entity/AccessToken.php
@@ -25,7 +25,7 @@ class AccessToken extends BaseAccessToken
25 protected $client; 25 protected $client;
26 26
27 /** 27 /**
28 * @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\User") 28 * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User")
29 */ 29 */
30 protected $user; 30 protected $user;
31} 31}
diff --git a/src/Wallabag/ApiBundle/Entity/AuthCode.php b/src/Wallabag/ApiBundle/Entity/AuthCode.php
index 7873d97d..81398158 100644
--- a/src/Wallabag/ApiBundle/Entity/AuthCode.php
+++ b/src/Wallabag/ApiBundle/Entity/AuthCode.php
@@ -25,7 +25,7 @@ class AuthCode extends BaseAuthCode
25 protected $client; 25 protected $client;
26 26
27 /** 27 /**
28 * @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\User") 28 * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User")
29 */ 29 */
30 protected $user; 30 protected $user;
31} 31}
diff --git a/src/Wallabag/ApiBundle/Entity/RefreshToken.php b/src/Wallabag/ApiBundle/Entity/RefreshToken.php
index 74c564b7..be2c1d2e 100644
--- a/src/Wallabag/ApiBundle/Entity/RefreshToken.php
+++ b/src/Wallabag/ApiBundle/Entity/RefreshToken.php
@@ -25,7 +25,7 @@ class RefreshToken extends BaseRefreshToken
25 protected $client; 25 protected $client;
26 26
27 /** 27 /**
28 * @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\User") 28 * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User")
29 */ 29 */
30 protected $user; 30 protected $user;
31} 31}
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php
index 1bd76ae3..140fdf9e 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
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index 27c323b7..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;
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
index 811451da..d48855da 100644
--- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadUserData.php
+++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadUserData.php
@@ -1,11 +1,11 @@
1<?php 1<?php
2 2
3namespace Wallabag\CoreBundle\DataFixtures\ORM; 3namespace Wallabag\UserBundle\DataFixtures\ORM;
4 4
5use Doctrine\Common\DataFixtures\AbstractFixture; 5use Doctrine\Common\DataFixtures\AbstractFixture;
6use Doctrine\Common\DataFixtures\OrderedFixtureInterface; 6use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
7use Doctrine\Common\Persistence\ObjectManager; 7use Doctrine\Common\Persistence\ObjectManager;
8use Wallabag\CoreBundle\Entity\User; 8use Wallabag\UserBundle\Entity\User;
9 9
10class LoadUserData extends AbstractFixture implements OrderedFixtureInterface 10class LoadUserData extends AbstractFixture implements OrderedFixtureInterface
11{ 11{
diff --git a/src/Wallabag/CoreBundle/Entity/Config.php b/src/Wallabag/CoreBundle/Entity/Config.php
index 025d94ef..ddd4f7d9 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..f6206a09 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..6067360f 100644
--- a/src/Wallabag/CoreBundle/Entity/Tag.php
+++ b/src/Wallabag/CoreBundle/Entity/Tag.php
@@ -42,7 +42,7 @@ 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
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
index 9e95eb47..5614d8b2 100644
--- a/src/Wallabag/CoreBundle/Form/Type/ForgotPasswordType.php
+++ b/src/Wallabag/CoreBundle/Form/Type/ForgotPasswordType.php
@@ -39,7 +39,7 @@ class ForgotPasswordType extends AbstractType
39 public function validateEmail($email, ExecutionContextInterface $context) 39 public function validateEmail($email, ExecutionContextInterface $context)
40 { 40 {
41 $user = $this->doctrine 41 $user = $this->doctrine
42 ->getRepository('WallabagCoreBundle:User') 42 ->getRepository('WallabagUserBundle:User')
43 ->findOneByEmail($email); 43 ->findOneByEmail($email);
44 44
45 if (!$user) { 45 if (!$user) {
diff --git a/src/Wallabag/CoreBundle/Form/Type/NewUserType.php b/src/Wallabag/CoreBundle/Form/Type/NewUserType.php
index ea7bb7ae..8aabc8bb 100644
--- a/src/Wallabag/CoreBundle/Form/Type/NewUserType.php
+++ b/src/Wallabag/CoreBundle/Form/Type/NewUserType.php
@@ -31,7 +31,7 @@ class NewUserType extends AbstractType
31 public function configureOptions(OptionsResolver $resolver) 31 public function configureOptions(OptionsResolver $resolver)
32 { 32 {
33 $resolver->setDefaults(array( 33 $resolver->setDefaults(array(
34 'data_class' => 'Wallabag\CoreBundle\Entity\User', 34 'data_class' => 'Wallabag\UserBundle\Entity\User',
35 )); 35 ));
36 } 36 }
37 37
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/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/Security/login.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Security/login.html.twig
index 10f380fe..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
@@ -54,7 +54,7 @@
54 </form> 54 </form>
55 </div> 55 </div>
56 <div class="center"> 56 <div class="center">
57 <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>
58 </div> 58 </div>
59 </div> 59 </div>
60 </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/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 708a07b1..3da5e8b7 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
@@ -354,7 +354,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
354 354
355 $em = $client->getContainer()->get('doctrine.orm.entity_manager'); 355 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
356 $user = $em 356 $user = $em
357 ->getRepository('WallabagCoreBundle:User') 357 ->getRepository('WallabagUserBundle:User')
358 ->findOneByUsername('wallace'); 358 ->findOneByUsername('wallace');
359 359
360 $this->assertTrue(false !== $user); 360 $this->assertTrue(false !== $user);
@@ -369,7 +369,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
369 // reset the token 369 // reset the token
370 $em = $client->getContainer()->get('doctrine.orm.entity_manager'); 370 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
371 $user = $em 371 $user = $em
372 ->getRepository('WallabagCoreBundle:User') 372 ->getRepository('WallabagUserBundle:User')
373 ->findOneByUsername('admin'); 373 ->findOneByUsername('admin');
374 374
375 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 7af9d5c4..00000000
--- a/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php
+++ /dev/null
@@ -1,319 +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 testRegister()
12 {
13 $client = $this->getClient();
14
15 $crawler = $client->request('GET', '/register/');
16
17 $this->assertEquals(200, $client->getResponse()->getStatusCode());
18 $this->assertContains('Register', $client->getResponse()->getContent());
19 }
20
21 public function dataForCreateAccountFailed()
22 {
23 return array(
24 array(
25 array(
26 'fos_user_registration_form[email]' => '',
27 'fos_user_registration_form[username]' => 'newuser',
28 'fos_user_registration_form[plainPassword][first]' => 'mypassword',
29 'fos_user_registration_form[plainPassword][second]' => 'mypassword',
30 ),
31 'Please enter an email',
32 ),
33 array(
34 array(
35 'fos_user_registration_form[email]' => 'newuser@wallabag.org',
36 'fos_user_registration_form[username]' => 'admin',
37 'fos_user_registration_form[plainPassword][first]' => 'mypassword',
38 'fos_user_registration_form[plainPassword][second]' => 'mypassword',
39 ),
40 'The username is already used',
41 ),
42 array(
43 array(
44 'fos_user_registration_form[email]' => 'newuser@wallabag.org',
45 'fos_user_registration_form[username]' => 'newuser',
46 'fos_user_registration_form[plainPassword][first]' => 'mypassword1',
47 'fos_user_registration_form[plainPassword][second]' => 'mypassword2',
48 ),
49 'The entered passwords don&#039;t match',
50 ),
51 );
52 }
53
54 /**
55 * @dataProvider dataForCreateAccountFailed
56 */
57 public function testCreateAccountFailed($data, $expectedMessage)
58 {
59 $client = $this->getClient();
60
61 $crawler = $client->request('GET', '/register/');
62
63 $form = $crawler->filter('input[type=submit]')->form();
64
65 $client->submit($form, $data);
66
67 $this->assertEquals(200, $client->getResponse()->getStatusCode());
68 $this->assertContains($expectedMessage, $client->getResponse()->getContent());
69 }
70
71 public function dataForCreateAccountSuccess()
72 {
73 return array(
74 array(
75 array(
76 'fos_user_registration_form[email]' => 'newuser@wallabag.org',
77 'fos_user_registration_form[username]' => 'newuser',
78 'fos_user_registration_form[plainPassword][first]' => 'mypassword',
79 'fos_user_registration_form[plainPassword][second]' => 'mypassword',
80 ),
81 ),
82 );
83 }
84
85 /**
86 * @dataProvider dataForCreateAccountSuccess
87 */
88 public function testCreateAccountSuccess($data)
89 {
90 $client = $this->getClient();
91
92 $crawler = $client->request('GET', '/register/');
93
94 $form = $crawler->filter('input[type=submit]')->form();
95
96 $client->submit($form, $data);
97 $this->assertEquals(302, $client->getResponse()->getStatusCode());
98
99 $crawler = $client->followRedirect();
100
101 $this->assertContains('The user has been created successfully', $client->getResponse()->getContent());
102 }
103
104 public function testRegistrationConfirmation()
105 {
106 $client = $this->getClient();
107 $client->followRedirects();
108
109 $user = $client->getContainer()
110 ->get('doctrine.orm.entity_manager')
111 ->getRepository('WallabagCoreBundle:User')
112 ->findOneByUsername('newuser');
113
114 $this->assertNull($user->getConfig());
115
116 $client->request('GET', '/register/confirm/b4dT0k3n');
117 $this->assertEquals(404, $client->getResponse()->getStatusCode());
118
119 $crawler = $client->request('GET', '/register/confirm/'.$user->getConfirmationToken());
120 $this->assertEquals(200, $client->getResponse()->getStatusCode());
121
122 $user = $client->getContainer()
123 ->get('doctrine.orm.entity_manager')
124 ->getRepository('WallabagCoreBundle:User')
125 ->findOneByUsername('newuser');
126 $this->assertNotNull($user->getConfig());
127 }
128
129 public function testLogin()
130 {
131 $client = $this->getClient();
132
133 $crawler = $client->request('GET', '/new');
134
135 $this->assertEquals(302, $client->getResponse()->getStatusCode());
136 $this->assertContains('login', $client->getResponse()->headers->get('location'));
137 }
138
139 public function testLoginFail()
140 {
141 $client = $this->getClient();
142
143 $crawler = $client->request('GET', '/login');
144
145 $form = $crawler->filter('button[type=submit]')->form();
146 $data = array(
147 '_username' => 'admin',
148 '_password' => 'admin',
149 );
150
151 $client->submit($form, $data);
152
153 $this->assertEquals(302, $client->getResponse()->getStatusCode());
154 $this->assertContains('login', $client->getResponse()->headers->get('location'));
155
156 $crawler = $client->followRedirect();
157
158 $this->assertContains('Bad credentials', $client->getResponse()->getContent());
159 }
160
161 public function testRedirectionAfterLogin()
162 {
163 $client = $this->getClient();
164 $client->followRedirects();
165
166 $crawler = $client->request('GET', '/config');
167
168 $form = $crawler->filter('button[type=submit]')->form();
169
170 $data = array(
171 '_username' => 'admin',
172 '_password' => 'mypassword',
173 );
174
175 $client->submit($form, $data);
176
177 $this->assertContains('RSS', $client->getResponse()->getContent());
178 }
179
180 public function testForgotPassword()
181 {
182 $client = $this->getClient();
183
184 $crawler = $client->request('GET', '/forgot-password');
185
186 $this->assertEquals(200, $client->getResponse()->getStatusCode());
187
188 $this->assertContains('Forgot password', $client->getResponse()->getContent());
189
190 $form = $crawler->filter('button[type=submit]');
191
192 $this->assertCount(1, $form);
193
194 return array(
195 'form' => $form->form(),
196 'client' => $client,
197 );
198 }
199
200 /**
201 * @depends testForgotPassword
202 */
203 public function testSubmitForgotPasswordFail($parameters)
204 {
205 $form = $parameters['form'];
206 $client = $parameters['client'];
207
208 $data = array(
209 'forgot_password[email]' => 'material',
210 );
211
212 $client->submit($form, $data);
213
214 $this->assertEquals(200, $client->getResponse()->getStatusCode());
215 $this->assertContains('No user found with this email', $client->getResponse()->getContent());
216 }
217
218 /**
219 * @depends testForgotPassword
220 *
221 * Instead of using collector which slow down the test suite
222 * http://symfony.com/doc/current/cookbook/email/testing.html
223 *
224 * Use a different way where Swift store email as file
225 */
226 public function testSubmitForgotPassword($parameters)
227 {
228 $form = $parameters['form'];
229 $client = $parameters['client'];
230
231 $spoolDir = $client->getKernel()->getContainer()->getParameter('swiftmailer.spool.default.file.path');
232
233 // cleanup pool dir
234 $filesystem = new Filesystem();
235 $filesystem->remove($spoolDir);
236
237 // to use `getCollector` since `collect: false` in config_test.yml
238 $client->enableProfiler();
239
240 $data = array(
241 'forgot_password[email]' => 'bobby@wallabag.org',
242 );
243
244 $client->submit($form, $data);
245
246 $this->assertEquals(302, $client->getResponse()->getStatusCode());
247
248 $crawler = $client->followRedirect();
249
250 $this->assertContains('An email has been sent to', $client->getResponse()->getContent());
251
252 // find every files (ie: emails) inside the spool dir except hidden files
253 $finder = new Finder();
254 $finder
255 ->in($spoolDir)
256 ->ignoreDotFiles(true)
257 ->files();
258
259 $this->assertCount(1, $finder, 'Only one email has been sent');
260
261 foreach ($finder as $file) {
262 $message = unserialize(file_get_contents($file));
263
264 $this->assertInstanceOf('Swift_Message', $message);
265 $this->assertEquals('Reset Password', $message->getSubject());
266 $this->assertEquals('no-reply@wallabag.org', key($message->getFrom()));
267 $this->assertEquals('bobby@wallabag.org', key($message->getTo()));
268 $this->assertContains(
269 'To reset your password - please visit',
270 $message->getBody()
271 );
272 }
273 }
274
275 public function testReset()
276 {
277 $client = $this->getClient();
278 $user = $client->getContainer()
279 ->get('doctrine.orm.entity_manager')
280 ->getRepository('WallabagCoreBundle:User')
281 ->findOneByEmail('bobby@wallabag.org');
282
283 $crawler = $client->request('GET', '/forgot-password/'.$user->getConfirmationToken());
284
285 $this->assertEquals(200, $client->getResponse()->getStatusCode());
286 $this->assertCount(2, $crawler->filter('input[type=password]'));
287 $this->assertCount(1, $form = $crawler->filter('button[type=submit]'));
288 $this->assertCount(1, $form);
289
290 $data = array(
291 'change_passwd[new_password][first]' => 'mypassword',
292 'change_passwd[new_password][second]' => 'mypassword',
293 );
294
295 $client->submit($form->form(), $data);
296
297 $this->assertEquals(302, $client->getResponse()->getStatusCode());
298 $this->assertContains('login', $client->getResponse()->headers->get('location'));
299 }
300
301 public function testResetBadToken()
302 {
303 $client = $this->getClient();
304
305 $client->request('GET', '/forgot-password/UIZOAU29UE902IEPZO');
306
307 $this->assertEquals(404, $client->getResponse()->getStatusCode());
308 }
309
310 public function testCheckEmailWithoutEmail()
311 {
312 $client = $this->getClient();
313
314 $client->request('GET', '/forgot-password/check-email');
315
316 $this->assertEquals(302, $client->getResponse()->getStatusCode());
317 $this->assertContains('forgot-password', $client->getResponse()->headers->get('location'));
318 }
319}
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
diff --git a/src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php b/src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php
index e5096528..756525a9 100644
--- a/src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php
+++ b/src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php
@@ -21,7 +21,7 @@ abstract class WallabagCoreTestCase extends WebTestCase
21 public function logInAs($username) 21 public function logInAs($username)
22 { 22 {
23 $crawler = $this->client->request('GET', '/login'); 23 $crawler = $this->client->request('GET', '/login');
24 $form = $crawler->filter('button[type=submit]')->form(); 24 $form = $crawler->filter('input[type=submit]')->form();
25 $data = array( 25 $data = array(
26 '_username' => $username, 26 '_username' => $username,
27 '_password' => 'mypassword', 27 '_password' => 'mypassword',
diff --git a/src/Wallabag/CoreBundle/Entity/User.php b/src/Wallabag/UserBundle/Entity/User.php
index ae2902a3..8f02e070 100644
--- a/src/Wallabag/CoreBundle/Entity/User.php
+++ b/src/Wallabag/UserBundle/Entity/User.php
@@ -1,6 +1,6 @@
1<?php 1<?php
2 2
3namespace Wallabag\CoreBundle\Entity; 3namespace Wallabag\UserBundle\Entity;
4 4
5use Doctrine\Common\Collections\ArrayCollection; 5use Doctrine\Common\Collections\ArrayCollection;
6use Doctrine\ORM\Mapping as ORM; 6use Doctrine\ORM\Mapping as ORM;
@@ -9,11 +9,14 @@ use Symfony\Component\Security\Core\User\UserInterface;
9use JMS\Serializer\Annotation\ExclusionPolicy; 9use JMS\Serializer\Annotation\ExclusionPolicy;
10use JMS\Serializer\Annotation\Expose; 10use JMS\Serializer\Annotation\Expose;
11use FOS\UserBundle\Model\User as BaseUser; 11use FOS\UserBundle\Model\User as BaseUser;
12use Wallabag\CoreBundle\Entity\Config;
13use Wallabag\CoreBundle\Entity\Entry;
14use Wallabag\CoreBundle\Entity\Tag;
12 15
13/** 16/**
14 * User. 17 * User.
15 * 18 *
16 * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\UserRepository") 19 * @ORM\Entity(repositoryClass="Wallabag\UserBundle\Repository\UserRepository")
17 * @ORM\Table 20 * @ORM\Table
18 * @ORM\HasLifecycleCallbacks() 21 * @ORM\HasLifecycleCallbacks()
19 * @ExclusionPolicy("all") 22 * @ExclusionPolicy("all")
@@ -55,17 +58,17 @@ class User extends BaseUser
55 protected $updatedAt; 58 protected $updatedAt;
56 59
57 /** 60 /**
58 * @ORM\OneToMany(targetEntity="Entry", mappedBy="user", cascade={"remove"}) 61 * @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\Entry", mappedBy="user", cascade={"remove"})
59 */ 62 */
60 protected $entries; 63 protected $entries;
61 64
62 /** 65 /**
63 * @ORM\OneToOne(targetEntity="Config", mappedBy="user") 66 * @ORM\OneToOne(targetEntity="Wallabag\CoreBundle\Entity\Config", mappedBy="user")
64 */ 67 */
65 protected $config; 68 protected $config;
66 69
67 /** 70 /**
68 * @ORM\OneToMany(targetEntity="Tag", mappedBy="user", cascade={"remove"}) 71 * @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\Tag", mappedBy="user", cascade={"remove"})
69 */ 72 */
70 protected $tags; 73 protected $tags;
71 74
@@ -178,11 +181,11 @@ class User extends BaseUser
178 /** 181 /**
179 * Set config. 182 * Set config.
180 * 183 *
181 * @param \Wallabag\CoreBundle\Entity\Config $config 184 * @param Config $config
182 * 185 *
183 * @return User 186 * @return User
184 */ 187 */
185 public function setConfig(\Wallabag\CoreBundle\Entity\Config $config = null) 188 public function setConfig(Config $config = null)
186 { 189 {
187 $this->config = $config; 190 $this->config = $config;
188 191
@@ -192,7 +195,7 @@ class User extends BaseUser
192 /** 195 /**
193 * Get config. 196 * Get config.
194 * 197 *
195 * @return \Wallabag\CoreBundle\Entity\Config 198 * @return Config
196 */ 199 */
197 public function getConfig() 200 public function getConfig()
198 { 201 {
diff --git a/src/Wallabag/CoreBundle/Repository/UserRepository.php b/src/Wallabag/UserBundle/Repository/UserRepository.php
index 968d0b49..c020f3ca 100644
--- a/src/Wallabag/CoreBundle/Repository/UserRepository.php
+++ b/src/Wallabag/UserBundle/Repository/UserRepository.php
@@ -1,6 +1,6 @@
1<?php 1<?php
2 2
3namespace Wallabag\CoreBundle\Repository; 3namespace Wallabag\UserBundle\Repository;
4 4
5use Doctrine\ORM\EntityRepository; 5use Doctrine\ORM\EntityRepository;
6 6
diff --git a/src/Wallabag/UserBundle/Resources/config/services.yml b/src/Wallabag/UserBundle/Resources/config/services.yml
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/Wallabag/UserBundle/Resources/config/services.yml
diff --git a/src/Wallabag/UserBundle/Resources/views/Default/index.html.twig b/src/Wallabag/UserBundle/Resources/views/Default/index.html.twig
new file mode 100644
index 00000000..4ce626e9
--- /dev/null
+++ b/src/Wallabag/UserBundle/Resources/views/Default/index.html.twig
@@ -0,0 +1 @@
Hello {{ name }}!
diff --git a/src/Wallabag/UserBundle/WallabagUserBundle.php b/src/Wallabag/UserBundle/WallabagUserBundle.php
new file mode 100644
index 00000000..e6e65042
--- /dev/null
+++ b/src/Wallabag/UserBundle/WallabagUserBundle.php
@@ -0,0 +1,9 @@
1<?php
2
3namespace Wallabag\UserBundle;
4
5use Symfony\Component\HttpKernel\Bundle\Bundle;
6
7class WallabagUserBundle extends Bundle
8{
9}