File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 12
12
namespace App \Controller ;
13
13
14
14
use Symfony \Bundle \FrameworkBundle \Controller \AbstractController ;
15
+ use Symfony \Component \HttpFoundation \Request ;
15
16
use Symfony \Component \HttpFoundation \Response ;
16
17
use Symfony \Component \Routing \Annotation \Route ;
17
18
use Symfony \Component \Security \Http \Authentication \AuthenticationUtils ;
19
+ use Symfony \Component \Security \Http \Util \TargetPathTrait ;
18
20
19
21
/**
20
22
* Controller used to manage the application security.
25
27
*/
26
28
class SecurityController extends AbstractController
27
29
{
30
+ use TargetPathTrait;
31
+
28
32
/**
29
33
* @Route("/login", name="security_login")
30
34
*/
31
- public function login (AuthenticationUtils $ helper ): Response
35
+ public function login (Request $ request , AuthenticationUtils $ helper ): Response
32
36
{
37
+ // this statement solves an edge-case: if you change the locale in the login
38
+ // page, after a successful login you are redirected to a page in the previous
39
+ // locale. This code regenerates the referrer URL whenever the login page is
40
+ // browsed, to ensure that its locale is always the current one.
41
+ $ this ->saveTargetPath ($ request ->getSession (), 'main ' , $ this ->generateUrl ('admin_index ' ));
42
+
33
43
return $ this ->render ('security/login.html.twig ' , [
34
44
// last username entered by the user (if any)
35
45
'last_username ' => $ helper ->getLastUsername (),
You can’t perform that action at this time.
0 commit comments