aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/UserBundle
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2017-07-01 09:52:38 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2017-07-01 09:52:38 +0200
commitf808b01692a835673f328d7221ba8c212caa9b61 (patch)
tree0c3b1fc5b1ddbd7af72227303503177689e1d403 /src/Wallabag/UserBundle
parent822c877949aff8ae57677671115f8f4fc69588d5 (diff)
downloadwallabag-f808b01692a835673f328d7221ba8c212caa9b61.tar.gz
wallabag-f808b01692a835673f328d7221ba8c212caa9b61.tar.zst
wallabag-f808b01692a835673f328d7221ba8c212caa9b61.zip
Add a real configuration for CS-Fixer
Diffstat (limited to 'src/Wallabag/UserBundle')
-rw-r--r--src/Wallabag/UserBundle/Controller/ManageController.php48
-rw-r--r--src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php6
-rw-r--r--src/Wallabag/UserBundle/Entity/User.php36
-rw-r--r--src/Wallabag/UserBundle/EventListener/AuthenticationFailureListener.php2
-rw-r--r--src/Wallabag/UserBundle/EventListener/PasswordResettingListener.php2
-rw-r--r--src/Wallabag/UserBundle/Form/UserType.php10
-rw-r--r--src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php2
-rw-r--r--src/Wallabag/UserBundle/Repository/UserRepository.php2
8 files changed, 54 insertions, 54 deletions
diff --git a/src/Wallabag/UserBundle/Controller/ManageController.php b/src/Wallabag/UserBundle/Controller/ManageController.php
index 084f2c67..f3de656f 100644
--- a/src/Wallabag/UserBundle/Controller/ManageController.php
+++ b/src/Wallabag/UserBundle/Controller/ManageController.php
@@ -7,10 +7,10 @@ use FOS\UserBundle\FOSUserEvents;
7use Pagerfanta\Adapter\DoctrineORMAdapter; 7use Pagerfanta\Adapter\DoctrineORMAdapter;
8use Pagerfanta\Exception\OutOfRangeCurrentPageException; 8use Pagerfanta\Exception\OutOfRangeCurrentPageException;
9use Pagerfanta\Pagerfanta; 9use Pagerfanta\Pagerfanta;
10use Symfony\Component\HttpFoundation\Request;
11use Symfony\Bundle\FrameworkBundle\Controller\Controller;
12use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; 10use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
13use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 11use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
12use Symfony\Bundle\FrameworkBundle\Controller\Controller;
13use Symfony\Component\HttpFoundation\Request;
14use Wallabag\UserBundle\Entity\User; 14use Wallabag\UserBundle\Entity\User;
15use Wallabag\UserBundle\Form\SearchUserType; 15use Wallabag\UserBundle\Form\SearchUserType;
16 16
@@ -48,13 +48,13 @@ class ManageController extends Controller
48 $this->get('translator')->trans('flashes.user.notice.added', ['%username%' => $user->getUsername()]) 48 $this->get('translator')->trans('flashes.user.notice.added', ['%username%' => $user->getUsername()])
49 ); 49 );
50 50
51 return $this->redirectToRoute('user_edit', array('id' => $user->getId())); 51 return $this->redirectToRoute('user_edit', ['id' => $user->getId()]);
52 } 52 }
53 53
54 return $this->render('WallabagUserBundle:Manage:new.html.twig', array( 54 return $this->render('WallabagUserBundle:Manage:new.html.twig', [
55 'user' => $user, 55 'user' => $user,
56 'form' => $form->createView(), 56 'form' => $form->createView(),
57 )); 57 ]);
58 } 58 }
59 59
60 /** 60 /**
@@ -79,15 +79,15 @@ class ManageController extends Controller
79 $this->get('translator')->trans('flashes.user.notice.updated', ['%username%' => $user->getUsername()]) 79 $this->get('translator')->trans('flashes.user.notice.updated', ['%username%' => $user->getUsername()])
80 ); 80 );
81 81
82 return $this->redirectToRoute('user_edit', array('id' => $user->getId())); 82 return $this->redirectToRoute('user_edit', ['id' => $user->getId()]);
83 } 83 }
84 84
85 return $this->render('WallabagUserBundle:Manage:edit.html.twig', array( 85 return $this->render('WallabagUserBundle:Manage:edit.html.twig', [
86 'user' => $user, 86 'user' => $user,
87 'edit_form' => $editForm->createView(), 87 'edit_form' => $editForm->createView(),
88 'delete_form' => $deleteForm->createView(), 88 'delete_form' => $deleteForm->createView(),
89 'twofactor_auth' => $this->getParameter('twofactor_auth'), 89 'twofactor_auth' => $this->getParameter('twofactor_auth'),
90 )); 90 ]);
91 } 91 }
92 92
93 /** 93 /**
@@ -116,22 +116,6 @@ class ManageController extends Controller
116 } 116 }
117 117
118 /** 118 /**
119 * Creates a form to delete a User entity.
120 *
121 * @param User $user The User entity
122 *
123 * @return \Symfony\Component\Form\Form The form
124 */
125 private function createDeleteForm(User $user)
126 {
127 return $this->createFormBuilder()
128 ->setAction($this->generateUrl('user_delete', array('id' => $user->getId())))
129 ->setMethod('DELETE')
130 ->getForm()
131 ;
132 }
133
134 /**
135 * @param Request $request 119 * @param Request $request
136 * @param int $page 120 * @param int $page
137 * 121 *
@@ -175,4 +159,20 @@ class ManageController extends Controller
175 'users' => $pagerFanta, 159 'users' => $pagerFanta,
176 ]); 160 ]);
177 } 161 }
162
163 /**
164 * Creates a form to delete a User entity.
165 *
166 * @param User $user The User entity
167 *
168 * @return \Symfony\Component\Form\Form The form
169 */
170 private function createDeleteForm(User $user)
171 {
172 return $this->createFormBuilder()
173 ->setAction($this->generateUrl('user_delete', ['id' => $user->getId()]))
174 ->setMethod('DELETE')
175 ->getForm()
176 ;
177 }
178} 178}
diff --git a/src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php b/src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php
index 99040f69..5ca3482e 100644
--- a/src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php
+++ b/src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php
@@ -2,10 +2,10 @@
2 2
3namespace Wallabag\UserBundle\DependencyInjection; 3namespace Wallabag\UserBundle\DependencyInjection;
4 4
5use Symfony\Component\DependencyInjection\ContainerBuilder;
6use Symfony\Component\Config\FileLocator; 5use Symfony\Component\Config\FileLocator;
7use Symfony\Component\HttpKernel\DependencyInjection\Extension; 6use Symfony\Component\DependencyInjection\ContainerBuilder;
8use Symfony\Component\DependencyInjection\Loader; 7use Symfony\Component\DependencyInjection\Loader;
8use Symfony\Component\HttpKernel\DependencyInjection\Extension;
9 9
10class WallabagUserExtension extends Extension 10class WallabagUserExtension extends Extension
11{ 11{
@@ -14,7 +14,7 @@ class WallabagUserExtension extends Extension
14 $configuration = new Configuration(); 14 $configuration = new Configuration();
15 $config = $this->processConfiguration($configuration, $configs); 15 $config = $this->processConfiguration($configuration, $configs);
16 16
17 $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); 17 $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
18 $loader->load('services.yml'); 18 $loader->load('services.yml');
19 $container->setParameter('wallabag_user.registration_enabled', $config['registration_enabled']); 19 $container->setParameter('wallabag_user.registration_enabled', $config['registration_enabled']);
20 } 20 }
diff --git a/src/Wallabag/UserBundle/Entity/User.php b/src/Wallabag/UserBundle/Entity/User.php
index aba76ca7..20aca298 100644
--- a/src/Wallabag/UserBundle/Entity/User.php
+++ b/src/Wallabag/UserBundle/Entity/User.php
@@ -4,12 +4,12 @@ namespace 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;
7use FOS\UserBundle\Model\User as BaseUser;
8use JMS\Serializer\Annotation\Accessor;
7use JMS\Serializer\Annotation\Groups; 9use JMS\Serializer\Annotation\Groups;
8use JMS\Serializer\Annotation\XmlRoot; 10use JMS\Serializer\Annotation\XmlRoot;
9use JMS\Serializer\Annotation\Accessor;
10use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface; 11use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface;
11use Scheb\TwoFactorBundle\Model\TrustedComputerInterface; 12use Scheb\TwoFactorBundle\Model\TrustedComputerInterface;
12use FOS\UserBundle\Model\User as BaseUser;
13use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; 13use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
14use Symfony\Component\Security\Core\User\UserInterface; 14use Symfony\Component\Security\Core\User\UserInterface;
15use Wallabag\ApiBundle\Entity\Client; 15use Wallabag\ApiBundle\Entity\Client;
@@ -93,36 +93,36 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf
93 protected $config; 93 protected $config;
94 94
95 /** 95 /**
96 * @ORM\Column(type="integer", nullable=true) 96 * @var ArrayCollection
97 *
98 * @ORM\OneToMany(targetEntity="Wallabag\ApiBundle\Entity\Client", mappedBy="user", cascade={"remove"})
97 */ 99 */
98 private $authCode; 100 protected $clients;
99 101
100 /** 102 /**
101 * @var bool 103 * @see getFirstClient() below
102 * 104 *
103 * @ORM\Column(type="boolean") 105 * @Groups({"user_api_with_client"})
106 * @Accessor(getter="getFirstClient")
104 */ 107 */
105 private $twoFactorAuthentication = false; 108 protected $default_client;
106 109
107 /** 110 /**
108 * @ORM\Column(type="json_array", nullable=true) 111 * @ORM\Column(type="integer", nullable=true)
109 */ 112 */
110 private $trusted; 113 private $authCode;
111 114
112 /** 115 /**
113 * @var ArrayCollection 116 * @var bool
114 * 117 *
115 * @ORM\OneToMany(targetEntity="Wallabag\ApiBundle\Entity\Client", mappedBy="user", cascade={"remove"}) 118 * @ORM\Column(type="boolean")
116 */ 119 */
117 protected $clients; 120 private $twoFactorAuthentication = false;
118 121
119 /** 122 /**
120 * @see getFirstClient() below 123 * @ORM\Column(type="json_array", nullable=true)
121 *
122 * @Groups({"user_api_with_client"})
123 * @Accessor(getter="getFirstClient")
124 */ 124 */
125 protected $default_client; 125 private $trusted;
126 126
127 public function __construct() 127 public function __construct()
128 { 128 {
@@ -137,7 +137,7 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf
137 */ 137 */
138 public function timestamps() 138 public function timestamps()
139 { 139 {
140 if (is_null($this->createdAt)) { 140 if (null === $this->createdAt) {
141 $this->createdAt = new \DateTime(); 141 $this->createdAt = new \DateTime();
142 } 142 }
143 143
diff --git a/src/Wallabag/UserBundle/EventListener/AuthenticationFailureListener.php b/src/Wallabag/UserBundle/EventListener/AuthenticationFailureListener.php
index 10f13233..18f14a3a 100644
--- a/src/Wallabag/UserBundle/EventListener/AuthenticationFailureListener.php
+++ b/src/Wallabag/UserBundle/EventListener/AuthenticationFailureListener.php
@@ -35,6 +35,6 @@ class AuthenticationFailureListener implements EventSubscriberInterface
35 { 35 {
36 $request = $this->requestStack->getMasterRequest(); 36 $request = $this->requestStack->getMasterRequest();
37 37
38 $this->logger->error('Authentication failure for user "'.$request->request->get('_username').'", from IP "'.$request->getClientIp().'", with UA: "'.$request->server->get('HTTP_USER_AGENT').'".'); 38 $this->logger->error('Authentication failure for user "' . $request->request->get('_username') . '", from IP "' . $request->getClientIp() . '", with UA: "' . $request->server->get('HTTP_USER_AGENT') . '".');
39 } 39 }
40} 40}
diff --git a/src/Wallabag/UserBundle/EventListener/PasswordResettingListener.php b/src/Wallabag/UserBundle/EventListener/PasswordResettingListener.php
index 3a7f2637..7df093f1 100644
--- a/src/Wallabag/UserBundle/EventListener/PasswordResettingListener.php
+++ b/src/Wallabag/UserBundle/EventListener/PasswordResettingListener.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\UserBundle\EventListener; 3namespace Wallabag\UserBundle\EventListener;
4 4
5use FOS\UserBundle\FOSUserEvents;
6use FOS\UserBundle\Event\FormEvent; 5use FOS\UserBundle\Event\FormEvent;
6use FOS\UserBundle\FOSUserEvents;
7use Symfony\Component\EventDispatcher\EventSubscriberInterface; 7use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8use Symfony\Component\HttpFoundation\RedirectResponse; 8use Symfony\Component\HttpFoundation\RedirectResponse;
9use Symfony\Component\Routing\Generator\UrlGeneratorInterface; 9use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
diff --git a/src/Wallabag/UserBundle/Form/UserType.php b/src/Wallabag/UserBundle/Form/UserType.php
index d8cdbaf9..56fea640 100644
--- a/src/Wallabag/UserBundle/Form/UserType.php
+++ b/src/Wallabag/UserBundle/Form/UserType.php
@@ -3,12 +3,12 @@
3namespace Wallabag\UserBundle\Form; 3namespace Wallabag\UserBundle\Form;
4 4
5use Symfony\Component\Form\AbstractType; 5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\FormBuilderInterface;
7use Symfony\Component\OptionsResolver\OptionsResolver;
8use Symfony\Component\Form\Extension\Core\Type\CheckboxType; 6use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
7use Symfony\Component\Form\Extension\Core\Type\EmailType;
9use Symfony\Component\Form\Extension\Core\Type\SubmitType; 8use Symfony\Component\Form\Extension\Core\Type\SubmitType;
10use Symfony\Component\Form\Extension\Core\Type\TextType; 9use Symfony\Component\Form\Extension\Core\Type\TextType;
11use Symfony\Component\Form\Extension\Core\Type\EmailType; 10use Symfony\Component\Form\FormBuilderInterface;
11use Symfony\Component\OptionsResolver\OptionsResolver;
12 12
13class UserType extends AbstractType 13class UserType extends AbstractType
14{ 14{
@@ -50,8 +50,8 @@ class UserType extends AbstractType
50 */ 50 */
51 public function configureOptions(OptionsResolver $resolver) 51 public function configureOptions(OptionsResolver $resolver)
52 { 52 {
53 $resolver->setDefaults(array( 53 $resolver->setDefaults([
54 'data_class' => 'Wallabag\UserBundle\Entity\User', 54 'data_class' => 'Wallabag\UserBundle\Entity\User',
55 )); 55 ]);
56 } 56 }
57} 57}
diff --git a/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php
index 961208f2..aed805c9 100644
--- a/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php
+++ b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\UserBundle\Mailer; 3namespace Wallabag\UserBundle\Mailer;
4 4
5use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface;
6use Scheb\TwoFactorBundle\Mailer\AuthCodeMailerInterface; 5use Scheb\TwoFactorBundle\Mailer\AuthCodeMailerInterface;
6use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface;
7 7
8/** 8/**
9 * Custom mailer for TwoFactorBundle email. 9 * Custom mailer for TwoFactorBundle email.
diff --git a/src/Wallabag/UserBundle/Repository/UserRepository.php b/src/Wallabag/UserBundle/Repository/UserRepository.php
index 6adbe329..b1d753d2 100644
--- a/src/Wallabag/UserBundle/Repository/UserRepository.php
+++ b/src/Wallabag/UserBundle/Repository/UserRepository.php
@@ -63,6 +63,6 @@ class UserRepository extends EntityRepository
63 public function getQueryBuilderForSearch($term) 63 public function getQueryBuilderForSearch($term)
64 { 64 {
65 return $this->createQueryBuilder('u') 65 return $this->createQueryBuilder('u')
66 ->andWhere('lower(u.username) LIKE lower(:term) OR lower(u.email) LIKE lower(:term) OR lower(u.name) LIKE lower(:term)')->setParameter('term', '%'.$term.'%'); 66 ->andWhere('lower(u.username) LIKE lower(:term) OR lower(u.email) LIKE lower(:term) OR lower(u.name) LIKE lower(:term)')->setParameter('term', '%' . $term . '%');
67 } 67 }
68} 68}