diff options
Diffstat (limited to 'src/Wallabag/UserBundle')
-rw-r--r-- | src/Wallabag/UserBundle/Controller/ManageController.php | 45 | ||||
-rw-r--r-- | src/Wallabag/UserBundle/DataFixtures/UserFixtures.php (renamed from src/Wallabag/UserBundle/DataFixtures/ORM/LoadUserData.php) | 15 | ||||
-rw-r--r-- | src/Wallabag/UserBundle/Entity/User.php | 148 | ||||
-rw-r--r-- | src/Wallabag/UserBundle/EventListener/CreateConfigListener.php | 13 | ||||
-rw-r--r-- | src/Wallabag/UserBundle/Form/UserType.php | 9 | ||||
-rw-r--r-- | src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php | 4 | ||||
-rw-r--r-- | src/Wallabag/UserBundle/Repository/UserRepository.php | 8 | ||||
-rw-r--r-- | src/Wallabag/UserBundle/Resources/config/services.yml | 3 | ||||
-rw-r--r-- | src/Wallabag/UserBundle/Resources/views/Authentication/form.html.twig | 14 | ||||
-rw-r--r-- | src/Wallabag/UserBundle/Resources/views/Manage/edit.html.twig | 11 | ||||
-rw-r--r-- | src/Wallabag/UserBundle/Resources/views/Registration/register_content.html.twig | 1 | ||||
-rw-r--r-- | src/Wallabag/UserBundle/Resources/views/layout.html.twig | 5 |
12 files changed, 198 insertions, 78 deletions
diff --git a/src/Wallabag/UserBundle/Controller/ManageController.php b/src/Wallabag/UserBundle/Controller/ManageController.php index f3de656f..63a06206 100644 --- a/src/Wallabag/UserBundle/Controller/ManageController.php +++ b/src/Wallabag/UserBundle/Controller/ManageController.php | |||
@@ -7,10 +7,9 @@ use FOS\UserBundle\FOSUserEvents; | |||
7 | use Pagerfanta\Adapter\DoctrineORMAdapter; | 7 | use Pagerfanta\Adapter\DoctrineORMAdapter; |
8 | use Pagerfanta\Exception\OutOfRangeCurrentPageException; | 8 | use Pagerfanta\Exception\OutOfRangeCurrentPageException; |
9 | use Pagerfanta\Pagerfanta; | 9 | use Pagerfanta\Pagerfanta; |
10 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; | ||
11 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | ||
12 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | 10 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
13 | use Symfony\Component\HttpFoundation\Request; | 11 | use Symfony\Component\HttpFoundation\Request; |
12 | use Symfony\Component\Routing\Annotation\Route; | ||
14 | use Wallabag\UserBundle\Entity\User; | 13 | use Wallabag\UserBundle\Entity\User; |
15 | use Wallabag\UserBundle\Form\SearchUserType; | 14 | use Wallabag\UserBundle\Form\SearchUserType; |
16 | 15 | ||
@@ -22,8 +21,7 @@ class ManageController extends Controller | |||
22 | /** | 21 | /** |
23 | * Creates a new User entity. | 22 | * Creates a new User entity. |
24 | * | 23 | * |
25 | * @Route("/new", name="user_new") | 24 | * @Route("/new", name="user_new", methods={"GET", "POST"}) |
26 | * @Method({"GET", "POST"}) | ||
27 | */ | 25 | */ |
28 | public function newAction(Request $request) | 26 | public function newAction(Request $request) |
29 | { | 27 | { |
@@ -60,19 +58,33 @@ class ManageController extends Controller | |||
60 | /** | 58 | /** |
61 | * Displays a form to edit an existing User entity. | 59 | * Displays a form to edit an existing User entity. |
62 | * | 60 | * |
63 | * @Route("/{id}/edit", name="user_edit") | 61 | * @Route("/{id}/edit", name="user_edit", methods={"GET", "POST"}) |
64 | * @Method({"GET", "POST"}) | ||
65 | */ | 62 | */ |
66 | public function editAction(Request $request, User $user) | 63 | public function editAction(Request $request, User $user) |
67 | { | 64 | { |
65 | $userManager = $this->container->get('fos_user.user_manager'); | ||
66 | |||
68 | $deleteForm = $this->createDeleteForm($user); | 67 | $deleteForm = $this->createDeleteForm($user); |
69 | $editForm = $this->createForm('Wallabag\UserBundle\Form\UserType', $user); | 68 | $form = $this->createForm('Wallabag\UserBundle\Form\UserType', $user); |
70 | $editForm->handleRequest($request); | 69 | $form->handleRequest($request); |
71 | 70 | ||
72 | if ($editForm->isSubmitted() && $editForm->isValid()) { | 71 | // `googleTwoFactor` isn't a field within the User entity, we need to define it's value in a different way |
73 | $em = $this->getDoctrine()->getManager(); | 72 | if ($this->getParameter('twofactor_auth') && true === $user->isGoogleAuthenticatorEnabled() && false === $form->isSubmitted()) { |
74 | $em->persist($user); | 73 | $form->get('googleTwoFactor')->setData(true); |
75 | $em->flush(); | 74 | } |
75 | |||
76 | if ($form->isSubmitted() && $form->isValid()) { | ||
77 | // handle creation / reset of the OTP secret if checkbox changed from the previous state | ||
78 | if ($this->getParameter('twofactor_auth')) { | ||
79 | if (true === $form->get('googleTwoFactor')->getData() && false === $user->isGoogleAuthenticatorEnabled()) { | ||
80 | $user->setGoogleAuthenticatorSecret($this->get('scheb_two_factor.security.google_authenticator')->generateSecret()); | ||
81 | $user->setEmailTwoFactor(false); | ||
82 | } elseif (false === $form->get('googleTwoFactor')->getData() && true === $user->isGoogleAuthenticatorEnabled()) { | ||
83 | $user->setGoogleAuthenticatorSecret(null); | ||
84 | } | ||
85 | } | ||
86 | |||
87 | $userManager->updateUser($user); | ||
76 | 88 | ||
77 | $this->get('session')->getFlashBag()->add( | 89 | $this->get('session')->getFlashBag()->add( |
78 | 'notice', | 90 | 'notice', |
@@ -84,7 +96,7 @@ class ManageController extends Controller | |||
84 | 96 | ||
85 | return $this->render('WallabagUserBundle:Manage:edit.html.twig', [ | 97 | return $this->render('WallabagUserBundle:Manage:edit.html.twig', [ |
86 | 'user' => $user, | 98 | 'user' => $user, |
87 | 'edit_form' => $editForm->createView(), | 99 | 'edit_form' => $form->createView(), |
88 | 'delete_form' => $deleteForm->createView(), | 100 | 'delete_form' => $deleteForm->createView(), |
89 | 'twofactor_auth' => $this->getParameter('twofactor_auth'), | 101 | 'twofactor_auth' => $this->getParameter('twofactor_auth'), |
90 | ]); | 102 | ]); |
@@ -93,8 +105,7 @@ class ManageController extends Controller | |||
93 | /** | 105 | /** |
94 | * Deletes a User entity. | 106 | * Deletes a User entity. |
95 | * | 107 | * |
96 | * @Route("/{id}", name="user_delete") | 108 | * @Route("/{id}", name="user_delete", methods={"DELETE"}) |
97 | * @Method("DELETE") | ||
98 | */ | 109 | */ |
99 | public function deleteAction(Request $request, User $user) | 110 | public function deleteAction(Request $request, User $user) |
100 | { | 111 | { |
@@ -135,8 +146,6 @@ class ManageController extends Controller | |||
135 | $form->handleRequest($request); | 146 | $form->handleRequest($request); |
136 | 147 | ||
137 | if ($form->isSubmitted() && $form->isValid()) { | 148 | if ($form->isSubmitted() && $form->isValid()) { |
138 | $this->get('logger')->info('searching users'); | ||
139 | |||
140 | $searchTerm = (isset($request->get('search_user')['term']) ? $request->get('search_user')['term'] : ''); | 149 | $searchTerm = (isset($request->get('search_user')['term']) ? $request->get('search_user')['term'] : ''); |
141 | 150 | ||
142 | $qb = $em->getRepository('WallabagUserBundle:User')->getQueryBuilderForSearch($searchTerm); | 151 | $qb = $em->getRepository('WallabagUserBundle:User')->getQueryBuilderForSearch($searchTerm); |
@@ -161,7 +170,7 @@ class ManageController extends Controller | |||
161 | } | 170 | } |
162 | 171 | ||
163 | /** | 172 | /** |
164 | * Creates a form to delete a User entity. | 173 | * Create a form to delete a User entity. |
165 | * | 174 | * |
166 | * @param User $user The User entity | 175 | * @param User $user The User entity |
167 | * | 176 | * |
diff --git a/src/Wallabag/UserBundle/DataFixtures/ORM/LoadUserData.php b/src/Wallabag/UserBundle/DataFixtures/UserFixtures.php index 26dbda3b..1e375e09 100644 --- a/src/Wallabag/UserBundle/DataFixtures/ORM/LoadUserData.php +++ b/src/Wallabag/UserBundle/DataFixtures/UserFixtures.php | |||
@@ -1,13 +1,12 @@ | |||
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace Wallabag\UserBundle\DataFixtures\ORM; | 3 | namespace Wallabag\UserBundle\DataFixtures; |
4 | 4 | ||
5 | use Doctrine\Common\DataFixtures\AbstractFixture; | 5 | use Doctrine\Bundle\FixturesBundle\Fixture; |
6 | use Doctrine\Common\DataFixtures\OrderedFixtureInterface; | ||
7 | use Doctrine\Common\Persistence\ObjectManager; | 6 | use Doctrine\Common\Persistence\ObjectManager; |
8 | use Wallabag\UserBundle\Entity\User; | 7 | use Wallabag\UserBundle\Entity\User; |
9 | 8 | ||
10 | class LoadUserData extends AbstractFixture implements OrderedFixtureInterface | 9 | class UserFixtures extends Fixture |
11 | { | 10 | { |
12 | /** | 11 | /** |
13 | * {@inheritdoc} | 12 | * {@inheritdoc} |
@@ -50,12 +49,4 @@ class LoadUserData extends AbstractFixture implements OrderedFixtureInterface | |||
50 | 49 | ||
51 | $manager->flush(); | 50 | $manager->flush(); |
52 | } | 51 | } |
53 | |||
54 | /** | ||
55 | * {@inheritdoc} | ||
56 | */ | ||
57 | public function getOrder() | ||
58 | { | ||
59 | return 10; | ||
60 | } | ||
61 | } | 52 | } |
diff --git a/src/Wallabag/UserBundle/Entity/User.php b/src/Wallabag/UserBundle/Entity/User.php index 48446e3c..43fa6a80 100644 --- a/src/Wallabag/UserBundle/Entity/User.php +++ b/src/Wallabag/UserBundle/Entity/User.php | |||
@@ -8,8 +8,9 @@ use FOS\UserBundle\Model\User as BaseUser; | |||
8 | use JMS\Serializer\Annotation\Accessor; | 8 | use JMS\Serializer\Annotation\Accessor; |
9 | use JMS\Serializer\Annotation\Groups; | 9 | use JMS\Serializer\Annotation\Groups; |
10 | use JMS\Serializer\Annotation\XmlRoot; | 10 | use JMS\Serializer\Annotation\XmlRoot; |
11 | use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface; | 11 | use Scheb\TwoFactorBundle\Model\BackupCodeInterface; |
12 | use Scheb\TwoFactorBundle\Model\TrustedComputerInterface; | 12 | use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface as EmailTwoFactorInterface; |
13 | use Scheb\TwoFactorBundle\Model\Google\TwoFactorInterface as GoogleTwoFactorInterface; | ||
13 | use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; | 14 | use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; |
14 | use Symfony\Component\Security\Core\User\UserInterface; | 15 | use Symfony\Component\Security\Core\User\UserInterface; |
15 | use Wallabag\ApiBundle\Entity\Client; | 16 | use Wallabag\ApiBundle\Entity\Client; |
@@ -28,7 +29,7 @@ use Wallabag\CoreBundle\Helper\EntityTimestampsTrait; | |||
28 | * @UniqueEntity("email") | 29 | * @UniqueEntity("email") |
29 | * @UniqueEntity("username") | 30 | * @UniqueEntity("username") |
30 | */ | 31 | */ |
31 | class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterface | 32 | class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorInterface, BackupCodeInterface |
32 | { | 33 | { |
33 | use EntityTimestampsTrait; | 34 | use EntityTimestampsTrait; |
34 | 35 | ||
@@ -123,16 +124,21 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf | |||
123 | private $authCode; | 124 | private $authCode; |
124 | 125 | ||
125 | /** | 126 | /** |
126 | * @var bool | 127 | * @ORM\Column(name="googleAuthenticatorSecret", type="string", nullable=true) |
127 | * | ||
128 | * @ORM\Column(type="boolean") | ||
129 | */ | 128 | */ |
130 | private $twoFactorAuthentication = false; | 129 | private $googleAuthenticatorSecret; |
131 | 130 | ||
132 | /** | 131 | /** |
133 | * @ORM\Column(type="json_array", nullable=true) | 132 | * @ORM\Column(type="json_array", nullable=true) |
134 | */ | 133 | */ |
135 | private $trusted; | 134 | private $backupCodes; |
135 | |||
136 | /** | ||
137 | * @var bool | ||
138 | * | ||
139 | * @ORM\Column(type="boolean") | ||
140 | */ | ||
141 | private $emailTwoFactor = false; | ||
136 | 142 | ||
137 | public function __construct() | 143 | public function __construct() |
138 | { | 144 | { |
@@ -233,49 +239,119 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf | |||
233 | /** | 239 | /** |
234 | * @return bool | 240 | * @return bool |
235 | */ | 241 | */ |
236 | public function isTwoFactorAuthentication() | 242 | public function isEmailTwoFactor() |
237 | { | 243 | { |
238 | return $this->twoFactorAuthentication; | 244 | return $this->emailTwoFactor; |
239 | } | 245 | } |
240 | 246 | ||
241 | /** | 247 | /** |
242 | * @param bool $twoFactorAuthentication | 248 | * @param bool $emailTwoFactor |
243 | */ | 249 | */ |
244 | public function setTwoFactorAuthentication($twoFactorAuthentication) | 250 | public function setEmailTwoFactor($emailTwoFactor) |
245 | { | 251 | { |
246 | $this->twoFactorAuthentication = $twoFactorAuthentication; | 252 | $this->emailTwoFactor = $emailTwoFactor; |
247 | } | 253 | } |
248 | 254 | ||
249 | public function isEmailAuthEnabled() | 255 | /** |
256 | * Used in the user config form to be "like" the email option. | ||
257 | */ | ||
258 | public function isGoogleTwoFactor() | ||
259 | { | ||
260 | return $this->isGoogleAuthenticatorEnabled(); | ||
261 | } | ||
262 | |||
263 | /** | ||
264 | * {@inheritdoc} | ||
265 | */ | ||
266 | public function isEmailAuthEnabled(): bool | ||
250 | { | 267 | { |
251 | return $this->twoFactorAuthentication; | 268 | return $this->emailTwoFactor; |
252 | } | 269 | } |
253 | 270 | ||
254 | public function getEmailAuthCode() | 271 | /** |
272 | * {@inheritdoc} | ||
273 | */ | ||
274 | public function getEmailAuthCode(): string | ||
255 | { | 275 | { |
256 | return $this->authCode; | 276 | return $this->authCode; |
257 | } | 277 | } |
258 | 278 | ||
259 | public function setEmailAuthCode($authCode) | 279 | /** |
280 | * {@inheritdoc} | ||
281 | */ | ||
282 | public function setEmailAuthCode(string $authCode): void | ||
260 | { | 283 | { |
261 | $this->authCode = $authCode; | 284 | $this->authCode = $authCode; |
262 | } | 285 | } |
263 | 286 | ||
264 | public function addTrustedComputer($token, \DateTime $validUntil) | 287 | /** |
288 | * {@inheritdoc} | ||
289 | */ | ||
290 | public function getEmailAuthRecipient(): string | ||
265 | { | 291 | { |
266 | $this->trusted[$token] = $validUntil->format('r'); | 292 | return $this->email; |
267 | } | 293 | } |
268 | 294 | ||
269 | public function isTrustedComputer($token) | 295 | /** |
296 | * {@inheritdoc} | ||
297 | */ | ||
298 | public function isGoogleAuthenticatorEnabled(): bool | ||
270 | { | 299 | { |
271 | if (isset($this->trusted[$token])) { | 300 | return $this->googleAuthenticatorSecret ? true : false; |
272 | $now = new \DateTime(); | 301 | } |
273 | $validUntil = new \DateTime($this->trusted[$token]); | ||
274 | 302 | ||
275 | return $now < $validUntil; | 303 | /** |
276 | } | 304 | * {@inheritdoc} |
305 | */ | ||
306 | public function getGoogleAuthenticatorUsername(): string | ||
307 | { | ||
308 | return $this->username; | ||
309 | } | ||
277 | 310 | ||
278 | return false; | 311 | /** |
312 | * {@inheritdoc} | ||
313 | */ | ||
314 | public function getGoogleAuthenticatorSecret(): string | ||
315 | { | ||
316 | return $this->googleAuthenticatorSecret; | ||
317 | } | ||
318 | |||
319 | /** | ||
320 | * {@inheritdoc} | ||
321 | */ | ||
322 | public function setGoogleAuthenticatorSecret(?string $googleAuthenticatorSecret): void | ||
323 | { | ||
324 | $this->googleAuthenticatorSecret = $googleAuthenticatorSecret; | ||
325 | } | ||
326 | |||
327 | public function setBackupCodes(array $codes = null) | ||
328 | { | ||
329 | $this->backupCodes = $codes; | ||
330 | } | ||
331 | |||
332 | public function getBackupCodes() | ||
333 | { | ||
334 | return $this->backupCodes; | ||
335 | } | ||
336 | |||
337 | /** | ||
338 | * {@inheritdoc} | ||
339 | */ | ||
340 | public function isBackupCode(string $code): bool | ||
341 | { | ||
342 | return false === $this->findBackupCode($code) ? false : true; | ||
343 | } | ||
344 | |||
345 | /** | ||
346 | * {@inheritdoc} | ||
347 | */ | ||
348 | public function invalidateBackupCode(string $code): void | ||
349 | { | ||
350 | $key = $this->findBackupCode($code); | ||
351 | |||
352 | if (false !== $key) { | ||
353 | unset($this->backupCodes[$key]); | ||
354 | } | ||
279 | } | 355 | } |
280 | 356 | ||
281 | /** | 357 | /** |
@@ -309,4 +385,24 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf | |||
309 | return $this->clients->first(); | 385 | return $this->clients->first(); |
310 | } | 386 | } |
311 | } | 387 | } |
388 | |||
389 | /** | ||
390 | * Try to find a backup code from the list of backup codes of the current user. | ||
391 | * | ||
392 | * @param string $code Given code from the user | ||
393 | * | ||
394 | * @return string|false | ||
395 | */ | ||
396 | private function findBackupCode(string $code) | ||
397 | { | ||
398 | foreach ($this->backupCodes as $key => $backupCode) { | ||
399 | // backup code are hashed using `password_hash` | ||
400 | // see ConfigController->otpAppAction | ||
401 | if (password_verify($code, $backupCode)) { | ||
402 | return $key; | ||
403 | } | ||
404 | } | ||
405 | |||
406 | return false; | ||
407 | } | ||
312 | } | 408 | } |
diff --git a/src/Wallabag/UserBundle/EventListener/CreateConfigListener.php b/src/Wallabag/UserBundle/EventListener/CreateConfigListener.php index e4d55c19..81954213 100644 --- a/src/Wallabag/UserBundle/EventListener/CreateConfigListener.php +++ b/src/Wallabag/UserBundle/EventListener/CreateConfigListener.php | |||
@@ -6,6 +6,7 @@ use Doctrine\ORM\EntityManager; | |||
6 | use FOS\UserBundle\Event\UserEvent; | 6 | use FOS\UserBundle\Event\UserEvent; |
7 | use FOS\UserBundle\FOSUserEvents; | 7 | use FOS\UserBundle\FOSUserEvents; |
8 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; | 8 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
9 | use Symfony\Component\HttpFoundation\Session\Session; | ||
9 | use Wallabag\CoreBundle\Entity\Config; | 10 | use Wallabag\CoreBundle\Entity\Config; |
10 | 11 | ||
11 | /** | 12 | /** |
@@ -17,22 +18,24 @@ class CreateConfigListener implements EventSubscriberInterface | |||
17 | private $em; | 18 | private $em; |
18 | private $theme; | 19 | private $theme; |
19 | private $itemsOnPage; | 20 | private $itemsOnPage; |
20 | private $rssLimit; | 21 | private $feedLimit; |
21 | private $language; | 22 | private $language; |
22 | private $readingSpeed; | 23 | private $readingSpeed; |
23 | private $actionMarkAsRead; | 24 | private $actionMarkAsRead; |
24 | private $listMode; | 25 | private $listMode; |
26 | private $session; | ||
25 | 27 | ||
26 | public function __construct(EntityManager $em, $theme, $itemsOnPage, $rssLimit, $language, $readingSpeed, $actionMarkAsRead, $listMode) | 28 | public function __construct(EntityManager $em, $theme, $itemsOnPage, $feedLimit, $language, $readingSpeed, $actionMarkAsRead, $listMode, Session $session) |
27 | { | 29 | { |
28 | $this->em = $em; | 30 | $this->em = $em; |
29 | $this->theme = $theme; | 31 | $this->theme = $theme; |
30 | $this->itemsOnPage = $itemsOnPage; | 32 | $this->itemsOnPage = $itemsOnPage; |
31 | $this->rssLimit = $rssLimit; | 33 | $this->feedLimit = $feedLimit; |
32 | $this->language = $language; | 34 | $this->language = $language; |
33 | $this->readingSpeed = $readingSpeed; | 35 | $this->readingSpeed = $readingSpeed; |
34 | $this->actionMarkAsRead = $actionMarkAsRead; | 36 | $this->actionMarkAsRead = $actionMarkAsRead; |
35 | $this->listMode = $listMode; | 37 | $this->listMode = $listMode; |
38 | $this->session = $session; | ||
36 | } | 39 | } |
37 | 40 | ||
38 | public static function getSubscribedEvents() | 41 | public static function getSubscribedEvents() |
@@ -51,8 +54,8 @@ class CreateConfigListener implements EventSubscriberInterface | |||
51 | $config = new Config($event->getUser()); | 54 | $config = new Config($event->getUser()); |
52 | $config->setTheme($this->theme); | 55 | $config->setTheme($this->theme); |
53 | $config->setItemsPerPage($this->itemsOnPage); | 56 | $config->setItemsPerPage($this->itemsOnPage); |
54 | $config->setRssLimit($this->rssLimit); | 57 | $config->setFeedLimit($this->feedLimit); |
55 | $config->setLanguage($this->language); | 58 | $config->setLanguage($this->session->get('_locale', $this->language)); |
56 | $config->setReadingSpeed($this->readingSpeed); | 59 | $config->setReadingSpeed($this->readingSpeed); |
57 | $config->setActionMarkAsRead($this->actionMarkAsRead); | 60 | $config->setActionMarkAsRead($this->actionMarkAsRead); |
58 | $config->setListMode($this->listMode); | 61 | $config->setListMode($this->listMode); |
diff --git a/src/Wallabag/UserBundle/Form/UserType.php b/src/Wallabag/UserBundle/Form/UserType.php index 56fea640..026db9a2 100644 --- a/src/Wallabag/UserBundle/Form/UserType.php +++ b/src/Wallabag/UserBundle/Form/UserType.php | |||
@@ -35,9 +35,14 @@ class UserType extends AbstractType | |||
35 | 'required' => false, | 35 | 'required' => false, |
36 | 'label' => 'user.form.enabled_label', | 36 | 'label' => 'user.form.enabled_label', |
37 | ]) | 37 | ]) |
38 | ->add('twoFactorAuthentication', CheckboxType::class, [ | 38 | ->add('emailTwoFactor', CheckboxType::class, [ |
39 | 'required' => false, | 39 | 'required' => false, |
40 | 'label' => 'user.form.twofactor_label', | 40 | 'label' => 'user.form.twofactor_email_label', |
41 | ]) | ||
42 | ->add('googleTwoFactor', CheckboxType::class, [ | ||
43 | 'required' => false, | ||
44 | 'label' => 'user.form.twofactor_google_label', | ||
45 | 'mapped' => false, | ||
41 | ]) | 46 | ]) |
42 | ->add('save', SubmitType::class, [ | 47 | ->add('save', SubmitType::class, [ |
43 | 'label' => 'user.form.save', | 48 | 'label' => 'user.form.save', |
diff --git a/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php index aed805c9..2797efde 100644 --- a/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php +++ b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php | |||
@@ -78,7 +78,7 @@ class AuthCodeMailer implements AuthCodeMailerInterface | |||
78 | * | 78 | * |
79 | * @param TwoFactorInterface $user | 79 | * @param TwoFactorInterface $user |
80 | */ | 80 | */ |
81 | public function sendAuthCode(TwoFactorInterface $user) | 81 | public function sendAuthCode(TwoFactorInterface $user): void |
82 | { | 82 | { |
83 | $template = $this->twig->loadTemplate('WallabagUserBundle:TwoFactor:email_auth_code.html.twig'); | 83 | $template = $this->twig->loadTemplate('WallabagUserBundle:TwoFactor:email_auth_code.html.twig'); |
84 | 84 | ||
@@ -97,7 +97,7 @@ class AuthCodeMailer implements AuthCodeMailerInterface | |||
97 | 97 | ||
98 | $message = new \Swift_Message(); | 98 | $message = new \Swift_Message(); |
99 | $message | 99 | $message |
100 | ->setTo($user->getEmail()) | 100 | ->setTo($user->getEmailAuthRecipient()) |
101 | ->setFrom($this->senderEmail, $this->senderName) | 101 | ->setFrom($this->senderEmail, $this->senderName) |
102 | ->setSubject($subject) | 102 | ->setSubject($subject) |
103 | ->setBody($bodyText, 'text/plain') | 103 | ->setBody($bodyText, 'text/plain') |
diff --git a/src/Wallabag/UserBundle/Repository/UserRepository.php b/src/Wallabag/UserBundle/Repository/UserRepository.php index be693d3b..4abd55f1 100644 --- a/src/Wallabag/UserBundle/Repository/UserRepository.php +++ b/src/Wallabag/UserBundle/Repository/UserRepository.php | |||
@@ -9,18 +9,18 @@ use Wallabag\UserBundle\Entity\User; | |||
9 | class UserRepository extends EntityRepository | 9 | class UserRepository extends EntityRepository |
10 | { | 10 | { |
11 | /** | 11 | /** |
12 | * Find a user by its username and rss roken. | 12 | * Find a user by its username and Feed token. |
13 | * | 13 | * |
14 | * @param string $username | 14 | * @param string $username |
15 | * @param string $rssToken | 15 | * @param string $feedToken |
16 | * | 16 | * |
17 | * @return User|null | 17 | * @return User|null |
18 | */ | 18 | */ |
19 | public function findOneByUsernameAndRsstoken($username, $rssToken) | 19 | public function findOneByUsernameAndFeedtoken($username, $feedToken) |
20 | { | 20 | { |
21 | return $this->createQueryBuilder('u') | 21 | return $this->createQueryBuilder('u') |
22 | ->leftJoin('u.config', 'c') | 22 | ->leftJoin('u.config', 'c') |
23 | ->where('c.rssToken = :rss_token')->setParameter('rss_token', $rssToken) | 23 | ->where('c.feedToken = :feed_token')->setParameter('feed_token', $feedToken) |
24 | ->andWhere('u.username = :username')->setParameter('username', $username) | 24 | ->andWhere('u.username = :username')->setParameter('username', $username) |
25 | ->getQuery() | 25 | ->getQuery() |
26 | ->getOneOrNullResult(); | 26 | ->getOneOrNullResult(); |
diff --git a/src/Wallabag/UserBundle/Resources/config/services.yml b/src/Wallabag/UserBundle/Resources/config/services.yml index d3925de3..2dcf3011 100644 --- a/src/Wallabag/UserBundle/Resources/config/services.yml +++ b/src/Wallabag/UserBundle/Resources/config/services.yml | |||
@@ -28,11 +28,12 @@ services: | |||
28 | - "@doctrine.orm.entity_manager" | 28 | - "@doctrine.orm.entity_manager" |
29 | - "%wallabag_core.theme%" | 29 | - "%wallabag_core.theme%" |
30 | - "%wallabag_core.items_on_page%" | 30 | - "%wallabag_core.items_on_page%" |
31 | - "%wallabag_core.rss_limit%" | 31 | - "%wallabag_core.feed_limit%" |
32 | - "%wallabag_core.language%" | 32 | - "%wallabag_core.language%" |
33 | - "%wallabag_core.reading_speed%" | 33 | - "%wallabag_core.reading_speed%" |
34 | - "%wallabag_core.action_mark_as_read%" | 34 | - "%wallabag_core.action_mark_as_read%" |
35 | - "%wallabag_core.list_mode%" | 35 | - "%wallabag_core.list_mode%" |
36 | - "@session" | ||
36 | tags: | 37 | tags: |
37 | - { name: kernel.event_subscriber } | 38 | - { name: kernel.event_subscriber } |
38 | 39 | ||
diff --git a/src/Wallabag/UserBundle/Resources/views/Authentication/form.html.twig b/src/Wallabag/UserBundle/Resources/views/Authentication/form.html.twig index c8471bdd..47a5cb78 100644 --- a/src/Wallabag/UserBundle/Resources/views/Authentication/form.html.twig +++ b/src/Wallabag/UserBundle/Resources/views/Authentication/form.html.twig | |||
@@ -1,7 +1,8 @@ | |||
1 | {# Override `vendor/scheb/two-factor-bundle/Resources/views/Authentication/form.html.twig` #} | ||
1 | {% extends "WallabagUserBundle::layout.html.twig" %} | 2 | {% extends "WallabagUserBundle::layout.html.twig" %} |
2 | 3 | ||
3 | {% block fos_user_content %} | 4 | {% block fos_user_content %} |
4 | <form class="form" action="" method="post"> | 5 | <form class="form" action="{{ path("2fa_login_check") }}" method="post"> |
5 | <div class="card-content"> | 6 | <div class="card-content"> |
6 | <div class="row"> | 7 | <div class="row"> |
7 | 8 | ||
@@ -9,14 +10,19 @@ | |||
9 | <p class="error">{{ flashMessage|trans }}</p> | 10 | <p class="error">{{ flashMessage|trans }}</p> |
10 | {% endfor %} | 11 | {% endfor %} |
11 | 12 | ||
13 | {# Authentication errors #} | ||
14 | {% if authenticationError %} | ||
15 | <p class="error">{{ authenticationError|trans(authenticationErrorData) }}</p> | ||
16 | {% endif %} | ||
17 | |||
12 | <div class="input-field col s12"> | 18 | <div class="input-field col s12"> |
13 | <label for="_auth_code">{{ "scheb_two_factor.auth_code"|trans }}</label> | 19 | <label for="_auth_code">{{ "scheb_two_factor.auth_code"|trans }}</label> |
14 | <input id="_auth_code" type="text" autocomplete="off" name="_auth_code" /> | 20 | <input id="_auth_code" type="text" autocomplete="off" name="{{ authCodeParameterName }}" /> |
15 | </div> | 21 | </div> |
16 | 22 | ||
17 | {% if useTrustedOption %} | 23 | {% if displayTrustedOption %} |
18 | <div class="input-field col s12"> | 24 | <div class="input-field col s12"> |
19 | <input id="_trusted" type="checkbox" name="_trusted" /> | 25 | <input id="_trusted" type="checkbox" name="{{ trustedParameterName }}" /> |
20 | <label for="_trusted">{{ "scheb_two_factor.trusted"|trans }}</label> | 26 | <label for="_trusted">{{ "scheb_two_factor.trusted"|trans }}</label> |
21 | </div> | 27 | </div> |
22 | {% endif %} | 28 | {% endif %} |
diff --git a/src/Wallabag/UserBundle/Resources/views/Manage/edit.html.twig b/src/Wallabag/UserBundle/Resources/views/Manage/edit.html.twig index 3ffd15f5..2de8f3a5 100644 --- a/src/Wallabag/UserBundle/Resources/views/Manage/edit.html.twig +++ b/src/Wallabag/UserBundle/Resources/views/Manage/edit.html.twig | |||
@@ -50,9 +50,14 @@ | |||
50 | {% if twofactor_auth %} | 50 | {% if twofactor_auth %} |
51 | <div class="row"> | 51 | <div class="row"> |
52 | <div class="input-field col s12"> | 52 | <div class="input-field col s12"> |
53 | {{ form_widget(edit_form.twoFactorAuthentication) }} | 53 | {{ form_widget(edit_form.emailTwoFactor) }} |
54 | {{ form_label(edit_form.twoFactorAuthentication) }} | 54 | {{ form_label(edit_form.emailTwoFactor) }} |
55 | {{ form_errors(edit_form.twoFactorAuthentication) }} | 55 | {{ form_errors(edit_form.emailTwoFactor) }} |
56 | </div> | ||
57 | <div class="input-field col s12"> | ||
58 | {{ form_widget(edit_form.googleTwoFactor) }} | ||
59 | {{ form_label(edit_form.googleTwoFactor) }} | ||
60 | {{ form_errors(edit_form.googleTwoFactor) }} | ||
56 | </div> | 61 | </div> |
57 | </div> | 62 | </div> |
58 | {% endif %} | 63 | {% endif %} |
diff --git a/src/Wallabag/UserBundle/Resources/views/Registration/register_content.html.twig b/src/Wallabag/UserBundle/Resources/views/Registration/register_content.html.twig index d0a85fc7..85cd4f0d 100644 --- a/src/Wallabag/UserBundle/Resources/views/Registration/register_content.html.twig +++ b/src/Wallabag/UserBundle/Resources/views/Registration/register_content.html.twig | |||
@@ -3,7 +3,6 @@ | |||
3 | {{ form_start(form, {'method': 'post', 'action': path('fos_user_registration_register'), 'attr': {'class': 'fos_user_registration_register'}}) }} | 3 | {{ form_start(form, {'method': 'post', 'action': path('fos_user_registration_register'), 'attr': {'class': 'fos_user_registration_register'}}) }} |
4 | <div class="card-content"> | 4 | <div class="card-content"> |
5 | <div class="row"> | 5 | <div class="row"> |
6 | |||
7 | {{ form_widget(form._token) }} | 6 | {{ form_widget(form._token) }} |
8 | 7 | ||
9 | {% for flashMessage in app.session.flashbag.get('notice') %} | 8 | {% for flashMessage in app.session.flashbag.get('notice') %} |
diff --git a/src/Wallabag/UserBundle/Resources/views/layout.html.twig b/src/Wallabag/UserBundle/Resources/views/layout.html.twig index f97e9870..a47b31d0 100644 --- a/src/Wallabag/UserBundle/Resources/views/layout.html.twig +++ b/src/Wallabag/UserBundle/Resources/views/layout.html.twig | |||
@@ -15,6 +15,11 @@ | |||
15 | {% block fos_user_content %} | 15 | {% block fos_user_content %} |
16 | {% endblock fos_user_content %} | 16 | {% endblock fos_user_content %} |
17 | </div> | 17 | </div> |
18 | <div class="center"> | ||
19 | <a href="{{ path('changeLocale', {'language': 'de'}) }}">Deutsch</a> – | ||
20 | <a href="{{ path('changeLocale', {'language': 'en'}) }}">English</a> – | ||
21 | <a href="{{ path('changeLocale', {'language': 'fr'}) }}">Français</a> | ||
22 | </div> | ||
18 | </div> | 23 | </div> |
19 | </main> | 24 | </main> |
20 | {% endblock %} | 25 | {% endblock %} |