diff options
author | Jérémy Benoist <j0k3r@users.noreply.github.com> | 2017-07-03 13:39:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-03 13:39:54 +0200 |
commit | 71e1cbc8eb5928d393b0772055d6b711e90a09b3 (patch) | |
tree | 71795eadcf13fda9198b8cd9a3da26d51826bbd9 /src/Wallabag/UserBundle | |
parent | 822c877949aff8ae57677671115f8f4fc69588d5 (diff) | |
parent | 38520658addc217f127b0627ea28dcf8d6e6178c (diff) | |
download | wallabag-71e1cbc8eb5928d393b0772055d6b711e90a09b3.tar.gz wallabag-71e1cbc8eb5928d393b0772055d6b711e90a09b3.tar.zst wallabag-71e1cbc8eb5928d393b0772055d6b711e90a09b3.zip |
Merge pull request #3258 from wallabag/cs-fixer
Add a real configuration for CS-Fixer
Diffstat (limited to 'src/Wallabag/UserBundle')
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; | |||
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 Symfony\Component\HttpFoundation\Request; | ||
11 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
12 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; | 10 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; |
13 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | 11 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
12 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
13 | use Symfony\Component\HttpFoundation\Request; | ||
14 | use Wallabag\UserBundle\Entity\User; | 14 | use Wallabag\UserBundle\Entity\User; |
15 | use Wallabag\UserBundle\Form\SearchUserType; | 15 | use 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 | ||
3 | namespace Wallabag\UserBundle\DependencyInjection; | 3 | namespace Wallabag\UserBundle\DependencyInjection; |
4 | 4 | ||
5 | use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
6 | use Symfony\Component\Config\FileLocator; | 5 | use Symfony\Component\Config\FileLocator; |
7 | use Symfony\Component\HttpKernel\DependencyInjection\Extension; | 6 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
8 | use Symfony\Component\DependencyInjection\Loader; | 7 | use Symfony\Component\DependencyInjection\Loader; |
8 | use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
9 | 9 | ||
10 | class WallabagUserExtension extends Extension | 10 | class 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 | ||
5 | use Doctrine\Common\Collections\ArrayCollection; | 5 | use Doctrine\Common\Collections\ArrayCollection; |
6 | use Doctrine\ORM\Mapping as ORM; | 6 | use Doctrine\ORM\Mapping as ORM; |
7 | use FOS\UserBundle\Model\User as BaseUser; | ||
8 | use JMS\Serializer\Annotation\Accessor; | ||
7 | use JMS\Serializer\Annotation\Groups; | 9 | use JMS\Serializer\Annotation\Groups; |
8 | use JMS\Serializer\Annotation\XmlRoot; | 10 | use JMS\Serializer\Annotation\XmlRoot; |
9 | use JMS\Serializer\Annotation\Accessor; | ||
10 | use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface; | 11 | use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface; |
11 | use Scheb\TwoFactorBundle\Model\TrustedComputerInterface; | 12 | use Scheb\TwoFactorBundle\Model\TrustedComputerInterface; |
12 | use FOS\UserBundle\Model\User as BaseUser; | ||
13 | use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; | 13 | use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; |
14 | use Symfony\Component\Security\Core\User\UserInterface; | 14 | use Symfony\Component\Security\Core\User\UserInterface; |
15 | use Wallabag\ApiBundle\Entity\Client; | 15 | use 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 | ||
3 | namespace Wallabag\UserBundle\EventListener; | 3 | namespace Wallabag\UserBundle\EventListener; |
4 | 4 | ||
5 | use FOS\UserBundle\FOSUserEvents; | ||
6 | use FOS\UserBundle\Event\FormEvent; | 5 | use FOS\UserBundle\Event\FormEvent; |
6 | use FOS\UserBundle\FOSUserEvents; | ||
7 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; | 7 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
8 | use Symfony\Component\HttpFoundation\RedirectResponse; | 8 | use Symfony\Component\HttpFoundation\RedirectResponse; |
9 | use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | 9 | use 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 @@ | |||
3 | namespace Wallabag\UserBundle\Form; | 3 | namespace Wallabag\UserBundle\Form; |
4 | 4 | ||
5 | use Symfony\Component\Form\AbstractType; | 5 | use Symfony\Component\Form\AbstractType; |
6 | use Symfony\Component\Form\FormBuilderInterface; | ||
7 | use Symfony\Component\OptionsResolver\OptionsResolver; | ||
8 | use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | 6 | use Symfony\Component\Form\Extension\Core\Type\CheckboxType; |
7 | use Symfony\Component\Form\Extension\Core\Type\EmailType; | ||
9 | use Symfony\Component\Form\Extension\Core\Type\SubmitType; | 8 | use Symfony\Component\Form\Extension\Core\Type\SubmitType; |
10 | use Symfony\Component\Form\Extension\Core\Type\TextType; | 9 | use Symfony\Component\Form\Extension\Core\Type\TextType; |
11 | use Symfony\Component\Form\Extension\Core\Type\EmailType; | 10 | use Symfony\Component\Form\FormBuilderInterface; |
11 | use Symfony\Component\OptionsResolver\OptionsResolver; | ||
12 | 12 | ||
13 | class UserType extends AbstractType | 13 | class 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 | ||
3 | namespace Wallabag\UserBundle\Mailer; | 3 | namespace Wallabag\UserBundle\Mailer; |
4 | 4 | ||
5 | use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface; | ||
6 | use Scheb\TwoFactorBundle\Mailer\AuthCodeMailerInterface; | 5 | use Scheb\TwoFactorBundle\Mailer\AuthCodeMailerInterface; |
6 | use 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 | } |