@@ -14,8 +14,8 @@ |
||
14 | 14 | */ |
15 | 15 | class Navigation |
16 | 16 | { |
17 | - use GuidTrait; |
|
18 | - use CreatedUpdatedTrait; |
|
17 | + use GuidTrait; |
|
18 | + use CreatedUpdatedTrait; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @var integer |
@@ -6,26 +6,26 @@ |
||
6 | 6 | |
7 | 7 | trait GuidTrait |
8 | 8 | { |
9 | - /** |
|
10 | - * @var string |
|
11 | - * |
|
12 | - * @ORM\Column(name="guid", type="string", length=255, nullable=true) |
|
13 | - */ |
|
14 | - private $guid; |
|
9 | + /** |
|
10 | + * @var string |
|
11 | + * |
|
12 | + * @ORM\Column(name="guid", type="string", length=255, nullable=true) |
|
13 | + */ |
|
14 | + private $guid; |
|
15 | 15 | |
16 | - /** |
|
17 | - * @return string |
|
18 | - */ |
|
19 | - public function getGuid() |
|
20 | - { |
|
21 | - return $this->guid; |
|
22 | - } |
|
16 | + /** |
|
17 | + * @return string |
|
18 | + */ |
|
19 | + public function getGuid() |
|
20 | + { |
|
21 | + return $this->guid; |
|
22 | + } |
|
23 | 23 | |
24 | - /** |
|
25 | - * @param string $guid |
|
26 | - */ |
|
27 | - public function setGuid($guid) |
|
28 | - { |
|
29 | - $this->guid = $guid; |
|
30 | - } |
|
24 | + /** |
|
25 | + * @param string $guid |
|
26 | + */ |
|
27 | + public function setGuid($guid) |
|
28 | + { |
|
29 | + $this->guid = $guid; |
|
30 | + } |
|
31 | 31 | } |
@@ -16,8 +16,8 @@ |
||
16 | 16 | */ |
17 | 17 | class AccessRight |
18 | 18 | { |
19 | - use GuidTrait; |
|
20 | - use CreatedUpdatedTrait; |
|
19 | + use GuidTrait; |
|
20 | + use CreatedUpdatedTrait; |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * @var integer |
@@ -8,24 +8,24 @@ |
||
8 | 8 | |
9 | 9 | class UserLogsRepository extends EntityRepository |
10 | 10 | { |
11 | - /** |
|
12 | - * @param int $page |
|
13 | - * @param int $max_per_page |
|
14 | - * @return Paginator |
|
15 | - */ |
|
16 | - public function findAllPaginated(int $page, int $max_per_page): Paginator |
|
17 | - { |
|
18 | - $qb = $this->createQueryBuilder('l')->orderBy('l.created_at', 'DESC'); |
|
19 | - $query = $qb->getQuery(); |
|
11 | + /** |
|
12 | + * @param int $page |
|
13 | + * @param int $max_per_page |
|
14 | + * @return Paginator |
|
15 | + */ |
|
16 | + public function findAllPaginated(int $page, int $max_per_page): Paginator |
|
17 | + { |
|
18 | + $qb = $this->createQueryBuilder('l')->orderBy('l.created_at', 'DESC'); |
|
19 | + $query = $qb->getQuery(); |
|
20 | 20 | |
21 | - $first_result = ($page - 1) * $max_per_page; |
|
22 | - $query->setFirstResult($first_result)->setMaxResults($max_per_page); |
|
23 | - $paginator = new Paginator($query); |
|
21 | + $first_result = ($page - 1) * $max_per_page; |
|
22 | + $query->setFirstResult($first_result)->setMaxResults($max_per_page); |
|
23 | + $paginator = new Paginator($query); |
|
24 | 24 | |
25 | - if (($paginator->count() <= $first_result) && $page != 1) { |
|
26 | - throw new NotFoundHttpException('La page demandée n\'existe pas.'); |
|
27 | - } |
|
25 | + if (($paginator->count() <= $first_result) && $page != 1) { |
|
26 | + throw new NotFoundHttpException('La page demandée n\'existe pas.'); |
|
27 | + } |
|
28 | 28 | |
29 | - return $paginator; |
|
30 | - } |
|
29 | + return $paginator; |
|
30 | + } |
|
31 | 31 | } |
@@ -14,17 +14,17 @@ discard block |
||
14 | 14 | */ |
15 | 15 | class User |
16 | 16 | { |
17 | - use GuidTrait; |
|
18 | - use CreatedUpdatedTrait; |
|
17 | + use GuidTrait; |
|
18 | + use CreatedUpdatedTrait; |
|
19 | 19 | |
20 | - /** |
|
21 | - * @var integer |
|
22 | - * |
|
23 | - * @ORM\Column(name="id", type="integer", nullable=false, options={"unsigned"=true}) |
|
24 | - * @ORM\Id |
|
25 | - * @ORM\GeneratedValue(strategy="IDENTITY") |
|
26 | - */ |
|
27 | - private $id; |
|
20 | + /** |
|
21 | + * @var integer |
|
22 | + * |
|
23 | + * @ORM\Column(name="id", type="integer", nullable=false, options={"unsigned"=true}) |
|
24 | + * @ORM\Id |
|
25 | + * @ORM\GeneratedValue(strategy="IDENTITY") |
|
26 | + */ |
|
27 | + private $id; |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * @var AccessRight |
@@ -32,63 +32,63 @@ discard block |
||
32 | 32 | * @ORM\ManyToOne(targetEntity="PiouPiou\RibsAdminBundle\Entity\AccessRight", inversedBy="users") |
33 | 33 | * @ORM\JoinColumn(name="id_access_right", referencedColumnName="id", nullable=true) |
34 | 34 | */ |
35 | - private $accessRightList; |
|
35 | + private $accessRightList; |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @var boolean |
39 | 39 | * |
40 | 40 | * @ORM\Column(name="admin", type="boolean", nullable=true, options={"default": false}) |
41 | 41 | */ |
42 | - private $admin; |
|
42 | + private $admin; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @var string |
|
46 | - * |
|
47 | - * @ORM\Column(name="firstname", type="string", length=255, nullable=false) |
|
48 | - */ |
|
49 | - private $firstname; |
|
44 | + /** |
|
45 | + * @var string |
|
46 | + * |
|
47 | + * @ORM\Column(name="firstname", type="string", length=255, nullable=false) |
|
48 | + */ |
|
49 | + private $firstname; |
|
50 | 50 | |
51 | - /** |
|
52 | - * @var string |
|
53 | - * |
|
54 | - * @ORM\Column(name="lastname", type="string", length=255, nullable=false) |
|
55 | - */ |
|
56 | - private $lastname; |
|
51 | + /** |
|
52 | + * @var string |
|
53 | + * |
|
54 | + * @ORM\Column(name="lastname", type="string", length=255, nullable=false) |
|
55 | + */ |
|
56 | + private $lastname; |
|
57 | 57 | |
58 | - /** |
|
59 | - * @var string |
|
60 | - * |
|
61 | - * @ORM\Column(name="adress", type="string", length=255, nullable=true) |
|
62 | - */ |
|
63 | - private $adress; |
|
58 | + /** |
|
59 | + * @var string |
|
60 | + * |
|
61 | + * @ORM\Column(name="adress", type="string", length=255, nullable=true) |
|
62 | + */ |
|
63 | + private $adress; |
|
64 | 64 | |
65 | - /** |
|
66 | - * @var string |
|
67 | - * |
|
68 | - * @ORM\Column(name="postal_code", type="string", length=100, nullable=true) |
|
69 | - */ |
|
70 | - private $postalCode; |
|
65 | + /** |
|
66 | + * @var string |
|
67 | + * |
|
68 | + * @ORM\Column(name="postal_code", type="string", length=100, nullable=true) |
|
69 | + */ |
|
70 | + private $postalCode; |
|
71 | 71 | |
72 | - /** |
|
73 | - * @var string |
|
74 | - * |
|
75 | - * @ORM\Column(name="country", type="string", length=100, nullable=true) |
|
76 | - */ |
|
77 | - private $country; |
|
72 | + /** |
|
73 | + * @var string |
|
74 | + * |
|
75 | + * @ORM\Column(name="country", type="string", length=100, nullable=true) |
|
76 | + */ |
|
77 | + private $country; |
|
78 | 78 | |
79 | - /** |
|
80 | - * @var string |
|
81 | - * |
|
82 | - * @ORM\Column(name="state", type="string", length=255, nullable=true) |
|
83 | - */ |
|
84 | - private $state; |
|
79 | + /** |
|
80 | + * @var string |
|
81 | + * |
|
82 | + * @ORM\Column(name="state", type="string", length=255, nullable=true) |
|
83 | + */ |
|
84 | + private $state; |
|
85 | 85 | |
86 | - /** |
|
87 | - * @var string |
|
88 | - * |
|
89 | - * @ORM\Column(name="access_rights", type="text", nullable=true) |
|
90 | - */ |
|
91 | - private $accessRights; |
|
86 | + /** |
|
87 | + * @var string |
|
88 | + * |
|
89 | + * @ORM\Column(name="access_rights", type="text", nullable=true) |
|
90 | + */ |
|
91 | + private $accessRights; |
|
92 | 92 | |
93 | 93 | /** |
94 | 94 | * @var boolean |
@@ -97,21 +97,21 @@ discard block |
||
97 | 97 | */ |
98 | 98 | private $archived = false; |
99 | 99 | |
100 | - /** |
|
101 | - * @return int |
|
102 | - */ |
|
103 | - public function getId() |
|
104 | - { |
|
105 | - return $this->id; |
|
106 | - } |
|
100 | + /** |
|
101 | + * @return int |
|
102 | + */ |
|
103 | + public function getId() |
|
104 | + { |
|
105 | + return $this->id; |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * @param int $id |
|
110 | - */ |
|
111 | - public function setId($id) |
|
112 | - { |
|
113 | - $this->id = $id; |
|
114 | - } |
|
108 | + /** |
|
109 | + * @param int $id |
|
110 | + */ |
|
111 | + public function setId($id) |
|
112 | + { |
|
113 | + $this->id = $id; |
|
114 | + } |
|
115 | 115 | |
116 | 116 | /** |
117 | 117 | * @return AccessRight |
@@ -145,117 +145,117 @@ discard block |
||
145 | 145 | $this->admin = $admin; |
146 | 146 | } |
147 | 147 | |
148 | - /** |
|
149 | - * @return string |
|
150 | - */ |
|
151 | - public function getFirstname() |
|
152 | - { |
|
153 | - return $this->firstname; |
|
154 | - } |
|
148 | + /** |
|
149 | + * @return string |
|
150 | + */ |
|
151 | + public function getFirstname() |
|
152 | + { |
|
153 | + return $this->firstname; |
|
154 | + } |
|
155 | 155 | |
156 | - /** |
|
157 | - * @param string $firstname |
|
158 | - */ |
|
159 | - public function setFirstname($firstname) |
|
160 | - { |
|
161 | - $this->firstname = $firstname; |
|
162 | - } |
|
156 | + /** |
|
157 | + * @param string $firstname |
|
158 | + */ |
|
159 | + public function setFirstname($firstname) |
|
160 | + { |
|
161 | + $this->firstname = $firstname; |
|
162 | + } |
|
163 | 163 | |
164 | - /** |
|
165 | - * @return string |
|
166 | - */ |
|
167 | - public function getLastname() |
|
168 | - { |
|
169 | - return $this->lastname; |
|
170 | - } |
|
164 | + /** |
|
165 | + * @return string |
|
166 | + */ |
|
167 | + public function getLastname() |
|
168 | + { |
|
169 | + return $this->lastname; |
|
170 | + } |
|
171 | 171 | |
172 | - /** |
|
173 | - * @param string $lastname |
|
174 | - */ |
|
175 | - public function setLastname($lastname) |
|
176 | - { |
|
177 | - $this->lastname = $lastname; |
|
178 | - } |
|
172 | + /** |
|
173 | + * @param string $lastname |
|
174 | + */ |
|
175 | + public function setLastname($lastname) |
|
176 | + { |
|
177 | + $this->lastname = $lastname; |
|
178 | + } |
|
179 | 179 | |
180 | - /** |
|
181 | - * @return string |
|
182 | - */ |
|
183 | - public function getAdress() |
|
184 | - { |
|
185 | - return $this->adress; |
|
186 | - } |
|
180 | + /** |
|
181 | + * @return string |
|
182 | + */ |
|
183 | + public function getAdress() |
|
184 | + { |
|
185 | + return $this->adress; |
|
186 | + } |
|
187 | 187 | |
188 | - /** |
|
189 | - * @param string $adress |
|
190 | - */ |
|
191 | - public function setAdress($adress) |
|
192 | - { |
|
193 | - $this->adress = $adress; |
|
194 | - } |
|
188 | + /** |
|
189 | + * @param string $adress |
|
190 | + */ |
|
191 | + public function setAdress($adress) |
|
192 | + { |
|
193 | + $this->adress = $adress; |
|
194 | + } |
|
195 | 195 | |
196 | - /** |
|
197 | - * @return string |
|
198 | - */ |
|
199 | - public function getPostalCode() |
|
200 | - { |
|
201 | - return $this->postalCode; |
|
202 | - } |
|
196 | + /** |
|
197 | + * @return string |
|
198 | + */ |
|
199 | + public function getPostalCode() |
|
200 | + { |
|
201 | + return $this->postalCode; |
|
202 | + } |
|
203 | 203 | |
204 | - /** |
|
205 | - * @param string $postalCode |
|
206 | - */ |
|
207 | - public function setPostalCode($postalCode) |
|
208 | - { |
|
209 | - $this->postalCode = $postalCode; |
|
210 | - } |
|
204 | + /** |
|
205 | + * @param string $postalCode |
|
206 | + */ |
|
207 | + public function setPostalCode($postalCode) |
|
208 | + { |
|
209 | + $this->postalCode = $postalCode; |
|
210 | + } |
|
211 | 211 | |
212 | - /** |
|
213 | - * @return string |
|
214 | - */ |
|
215 | - public function getCountry() |
|
216 | - { |
|
217 | - return $this->country; |
|
218 | - } |
|
212 | + /** |
|
213 | + * @return string |
|
214 | + */ |
|
215 | + public function getCountry() |
|
216 | + { |
|
217 | + return $this->country; |
|
218 | + } |
|
219 | 219 | |
220 | - /** |
|
221 | - * @param string $country |
|
222 | - */ |
|
223 | - public function setCountry($country) |
|
224 | - { |
|
225 | - $this->country = $country; |
|
226 | - } |
|
220 | + /** |
|
221 | + * @param string $country |
|
222 | + */ |
|
223 | + public function setCountry($country) |
|
224 | + { |
|
225 | + $this->country = $country; |
|
226 | + } |
|
227 | 227 | |
228 | - /** |
|
229 | - * @return string |
|
230 | - */ |
|
231 | - public function getState() |
|
232 | - { |
|
233 | - return $this->state; |
|
234 | - } |
|
228 | + /** |
|
229 | + * @return string |
|
230 | + */ |
|
231 | + public function getState() |
|
232 | + { |
|
233 | + return $this->state; |
|
234 | + } |
|
235 | 235 | |
236 | - /** |
|
237 | - * @param string $state |
|
238 | - */ |
|
239 | - public function setState($state) |
|
240 | - { |
|
241 | - $this->state = $state; |
|
242 | - } |
|
236 | + /** |
|
237 | + * @param string $state |
|
238 | + */ |
|
239 | + public function setState($state) |
|
240 | + { |
|
241 | + $this->state = $state; |
|
242 | + } |
|
243 | 243 | |
244 | - /** |
|
245 | - * @return string |
|
246 | - */ |
|
247 | - public function getAccessRights() |
|
248 | - { |
|
249 | - return $this->accessRights; |
|
250 | - } |
|
244 | + /** |
|
245 | + * @return string |
|
246 | + */ |
|
247 | + public function getAccessRights() |
|
248 | + { |
|
249 | + return $this->accessRights; |
|
250 | + } |
|
251 | 251 | |
252 | - /** |
|
253 | - * @param string $accessRights |
|
254 | - */ |
|
255 | - public function setAccessRights($accessRights) |
|
256 | - { |
|
257 | - $this->accessRights = $accessRights; |
|
258 | - } |
|
252 | + /** |
|
253 | + * @param string $accessRights |
|
254 | + */ |
|
255 | + public function setAccessRights($accessRights) |
|
256 | + { |
|
257 | + $this->accessRights = $accessRights; |
|
258 | + } |
|
259 | 259 | |
260 | 260 | /** |
261 | 261 | * @return boolean |
@@ -274,8 +274,8 @@ discard block |
||
274 | 274 | } |
275 | 275 | |
276 | 276 | public function __toString() |
277 | - { |
|
278 | - return $this->getFirstname() . " " . $this->getLastname(); |
|
279 | - } |
|
277 | + { |
|
278 | + return $this->getFirstname() . " " . $this->getLastname(); |
|
279 | + } |
|
280 | 280 | } |
281 | 281 |
@@ -9,12 +9,12 @@ |
||
9 | 9 | |
10 | 10 | class RibsAdminExtension extends Extension |
11 | 11 | { |
12 | - public function load(array $configs, ContainerBuilder $container) |
|
13 | - { |
|
14 | - $loader = new YamlFileLoader( |
|
15 | - $container, |
|
16 | - new FileLocator(__DIR__ . '/../Resources/config') |
|
17 | - ); |
|
18 | - $loader->load('services.yml'); |
|
19 | - } |
|
12 | + public function load(array $configs, ContainerBuilder $container) |
|
13 | + { |
|
14 | + $loader = new YamlFileLoader( |
|
15 | + $container, |
|
16 | + new FileLocator(__DIR__ . '/../Resources/config') |
|
17 | + ); |
|
18 | + $loader->load('services.yml'); |
|
19 | + } |
|
20 | 20 | } |
@@ -7,43 +7,43 @@ |
||
7 | 7 | |
8 | 8 | class CreateUpdateAwareListener |
9 | 9 | { |
10 | - /** |
|
11 | - * @var User |
|
12 | - */ |
|
13 | - private $user; |
|
10 | + /** |
|
11 | + * @var User |
|
12 | + */ |
|
13 | + private $user; |
|
14 | 14 | |
15 | - /** |
|
16 | - * CreateUpdateAwareListener constructor. |
|
17 | - * @param TokenStorage $tokenStorage |
|
18 | - */ |
|
19 | - public function __construct(TokenStorage $tokenStorage) |
|
20 | - { |
|
21 | - if ($tokenStorage->getToken() && is_object($tokenStorage->getToken()->getUser()) && $tokenStorage->getToken()->getUser()->getUser()) { |
|
22 | - $this->user = $tokenStorage->getToken()->getUser()->getUser(); |
|
23 | - } else { |
|
24 | - $this->user = null; |
|
25 | - } |
|
26 | - } |
|
15 | + /** |
|
16 | + * CreateUpdateAwareListener constructor. |
|
17 | + * @param TokenStorage $tokenStorage |
|
18 | + */ |
|
19 | + public function __construct(TokenStorage $tokenStorage) |
|
20 | + { |
|
21 | + if ($tokenStorage->getToken() && is_object($tokenStorage->getToken()->getUser()) && $tokenStorage->getToken()->getUser()->getUser()) { |
|
22 | + $this->user = $tokenStorage->getToken()->getUser()->getUser(); |
|
23 | + } else { |
|
24 | + $this->user = null; |
|
25 | + } |
|
26 | + } |
|
27 | 27 | |
28 | - public function prePersist($entity) |
|
29 | - { |
|
30 | - if ($this->user) { |
|
31 | - if ($entity->getCreatedBy() === null) { |
|
32 | - $entity->setCreatedAt(new \DateTime()); |
|
33 | - $entity->setCreatedBy($this->user); |
|
34 | - } |
|
35 | - if ($entity->getUpdatedBy() === null) { |
|
36 | - $entity->setUpdatedAt(new \DateTime()); |
|
37 | - $entity->setUpdatedBy($this->user); |
|
38 | - } |
|
39 | - } |
|
40 | - } |
|
28 | + public function prePersist($entity) |
|
29 | + { |
|
30 | + if ($this->user) { |
|
31 | + if ($entity->getCreatedBy() === null) { |
|
32 | + $entity->setCreatedAt(new \DateTime()); |
|
33 | + $entity->setCreatedBy($this->user); |
|
34 | + } |
|
35 | + if ($entity->getUpdatedBy() === null) { |
|
36 | + $entity->setUpdatedAt(new \DateTime()); |
|
37 | + $entity->setUpdatedBy($this->user); |
|
38 | + } |
|
39 | + } |
|
40 | + } |
|
41 | 41 | |
42 | - public function preUpdate($entity) |
|
43 | - { |
|
44 | - if ($this->user) { |
|
45 | - $entity->setUpdatedAt(new \DateTime()); |
|
46 | - $entity->setUpdatedBy($this->user); |
|
47 | - } |
|
48 | - } |
|
42 | + public function preUpdate($entity) |
|
43 | + { |
|
44 | + if ($this->user) { |
|
45 | + $entity->setUpdatedAt(new \DateTime()); |
|
46 | + $entity->setUpdatedBy($this->user); |
|
47 | + } |
|
48 | + } |
|
49 | 49 | } |
@@ -7,24 +7,24 @@ |
||
7 | 7 | |
8 | 8 | class GuidAwareListener |
9 | 9 | { |
10 | - /** |
|
11 | - * @var ContainerInterface |
|
12 | - */ |
|
13 | - private $container; |
|
10 | + /** |
|
11 | + * @var ContainerInterface |
|
12 | + */ |
|
13 | + private $container; |
|
14 | 14 | |
15 | - /** |
|
16 | - * GuidAwareListener constructor. |
|
17 | - * @param ContainerInterface $container |
|
18 | - */ |
|
19 | - public function __construct(ContainerInterface $container) |
|
20 | - { |
|
21 | - $this->container = $container; |
|
22 | - } |
|
15 | + /** |
|
16 | + * GuidAwareListener constructor. |
|
17 | + * @param ContainerInterface $container |
|
18 | + */ |
|
19 | + public function __construct(ContainerInterface $container) |
|
20 | + { |
|
21 | + $this->container = $container; |
|
22 | + } |
|
23 | 23 | |
24 | - public function prePersist($entity) |
|
25 | - { |
|
26 | - if ($entity->getGuid() === null) { |
|
27 | - $entity->setGuid((string)Uuid::uuid4()); |
|
28 | - } |
|
29 | - } |
|
24 | + public function prePersist($entity) |
|
25 | + { |
|
26 | + if ($entity->getGuid() === null) { |
|
27 | + $entity->setGuid((string)Uuid::uuid4()); |
|
28 | + } |
|
29 | + } |
|
30 | 30 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | public function prePersist($entity) |
25 | 25 | { |
26 | 26 | if ($entity->getGuid() === null) { |
27 | - $entity->setGuid((string)Uuid::uuid4()); |
|
27 | + $entity->setGuid((string) Uuid::uuid4()); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | } |
@@ -10,44 +10,44 @@ |
||
10 | 10 | |
11 | 11 | class LoginController extends AbstractController |
12 | 12 | { |
13 | - /** |
|
14 | - * @Route("/login/", name="ribsadmin_login") |
|
15 | - * @param AuthenticationUtils $auth_utils |
|
16 | - * @return Response |
|
17 | - */ |
|
18 | - public function loginAction(AuthenticationUtils $auth_utils): Response |
|
19 | - { |
|
20 | - $csrf_token = $this->has('security.csrf.token_manager') |
|
21 | - ? $this->get('security.csrf.token_manager')->getToken('authenticate')->getValue() |
|
22 | - : null; |
|
23 | - |
|
24 | - if ($auth_utils->getLastAuthenticationError()) { |
|
25 | - $this->addFlash("error-flash", "Your login or password are incorrect"); |
|
26 | - } |
|
27 | - |
|
28 | - // last username entered by the user |
|
29 | - $last_username = $auth_utils->getLastUsername(); |
|
30 | - |
|
31 | - return $this->render('@RibsAdmin/login/login.html.twig', array( |
|
32 | - 'last_username' => $last_username, |
|
33 | - 'csrf_token' => $csrf_token, |
|
34 | - )); |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * @param array $data |
|
39 | - * @return Response |
|
40 | - */ |
|
41 | - protected function renderLogin(array $data): Response |
|
42 | - { |
|
43 | - $securityContext = $this->get('security.authorization_checker'); |
|
44 | - |
|
45 | - if ($securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED') || $securityContext->isGranted('IS_AUTHENTICATED_FULLY')) { |
|
46 | - $this->addFlash("info-flash", "You were connected with success"); |
|
47 | - |
|
48 | - return new RedirectResponse($this->generateUrl("ribsadmin_index"), 303); |
|
49 | - } |
|
50 | - |
|
51 | - return $this->render("@RibsAdmin/login/login.html.twig", $data); |
|
52 | - } |
|
13 | + /** |
|
14 | + * @Route("/login/", name="ribsadmin_login") |
|
15 | + * @param AuthenticationUtils $auth_utils |
|
16 | + * @return Response |
|
17 | + */ |
|
18 | + public function loginAction(AuthenticationUtils $auth_utils): Response |
|
19 | + { |
|
20 | + $csrf_token = $this->has('security.csrf.token_manager') |
|
21 | + ? $this->get('security.csrf.token_manager')->getToken('authenticate')->getValue() |
|
22 | + : null; |
|
23 | + |
|
24 | + if ($auth_utils->getLastAuthenticationError()) { |
|
25 | + $this->addFlash("error-flash", "Your login or password are incorrect"); |
|
26 | + } |
|
27 | + |
|
28 | + // last username entered by the user |
|
29 | + $last_username = $auth_utils->getLastUsername(); |
|
30 | + |
|
31 | + return $this->render('@RibsAdmin/login/login.html.twig', array( |
|
32 | + 'last_username' => $last_username, |
|
33 | + 'csrf_token' => $csrf_token, |
|
34 | + )); |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * @param array $data |
|
39 | + * @return Response |
|
40 | + */ |
|
41 | + protected function renderLogin(array $data): Response |
|
42 | + { |
|
43 | + $securityContext = $this->get('security.authorization_checker'); |
|
44 | + |
|
45 | + if ($securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED') || $securityContext->isGranted('IS_AUTHENTICATED_FULLY')) { |
|
46 | + $this->addFlash("info-flash", "You were connected with success"); |
|
47 | + |
|
48 | + return new RedirectResponse($this->generateUrl("ribsadmin_index"), 303); |
|
49 | + } |
|
50 | + |
|
51 | + return $this->render("@RibsAdmin/login/login.html.twig", $data); |
|
52 | + } |
|
53 | 53 | } |