File tree 4 files changed +35
-1
lines changed
4 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ security:
22
22
23
23
# https://symfony.com/doc/current/security/impersonating_user.html
24
24
# switch_user: true
25
+ form_login :
26
+ login_path : app_login
27
+ check_path : app_login
25
28
26
29
# Easy way to control access for large sections of your site
27
30
# Note: Only the *first* access control that matches will be used
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace App \Controller ;
4
+
5
+ use Symfony \Bundle \FrameworkBundle \Controller \AbstractController ;
6
+ use Symfony \Component \HttpFoundation \Response ;
7
+ use Symfony \Component \Routing \Annotation \Route ;
8
+
9
+ class LoginController extends AbstractController
10
+ {
11
+ #[Route('/login ' , name: 'app_login ' )]
12
+ public function index (): Response
13
+ {
14
+ return $ this ->render ('login/index.html.twig ' );
15
+ }
16
+ }
Original file line number Diff line number Diff line change
1
+ {% extends ' base.html.twig' %}
2
+
3
+ {% block body %}
4
+ <form action =" {{ path(' app_login' ) }}" method =" post" >
5
+ <label for =" username" >Email:</label >
6
+ <input type =" text" id =" username" name =" _username" >
7
+
8
+ <label for =" password" >Password:</label >
9
+ <input type =" password" id =" password" name =" _password" >
10
+
11
+ <input type =" hidden" name =" _target_path" value =" /profile" >
12
+
13
+ <button type =" submit" >login</button >
14
+ </form >
15
+ {% endblock %}
Original file line number Diff line number Diff line change @@ -43,6 +43,6 @@ public function test(): void
43
43
public function testNotAuthenticated (): void
44
44
{
45
45
$ this ->client ->request ('GET ' , '/profile ' );
46
- $ this ->assertEquals ( 401 , $ this ->client ->getResponse ()->getStatusCode ( ));
46
+ $ this ->assertTrue ( $ this ->client ->getResponse ()->isRedirect ( ' http://localhost/login ' ));
47
47
}
48
48
}
You can’t perform that action at this time.
0 commit comments