@@ -74,10 +74,15 @@ class that processes the login submit and 4) updates the main security config fi
74
74
// last username entered by the user
75
75
$lastUsername = $authenticationUtils->getLastUsername();
76
76
77
- return $this->render('security/login.html.twig', [
78
- 'last_username' => $lastUsername,
79
- 'error' => $error
80
- ]);
77
+ return $this->render('security/login.html.twig', ['last_username' => $lastUsername, 'error' => $error]);
78
+ }
79
+
80
+ /**
81
+ * @Route("/logout", name="app_logout")
82
+ */
83
+ public function logout()
84
+ {
85
+ throw new \Exception('This method can be blank - it will be intercepted by the logout key on your firewall');
81
86
}
82
87
83
88
/**
@@ -165,10 +170,10 @@ a traditional HTML form that submits to ``/login``:
165
170
{% endif %}
166
171
167
172
<h1 class="h3 mb-3 font-weight-normal">Please sign in</h1>
168
- <label for="inputEmail" class="sr-only" >Email</label>
169
- <input type="email" value="{{ last_username }}" name="email" id="inputEmail" class="form-control" placeholder="Email" required autofocus>
170
- <label for="inputPassword" class="sr-only" >Password</label>
171
- <input type="password" name="password" id="inputPassword" class="form-control" placeholder="Password" required>
173
+ <label for="inputEmail">Email</label>
174
+ <input type="email" value="{{ last_username }}" name="email" id="inputEmail" class="form-control" required autofocus>
175
+ <label for="inputPassword">Password</label>
176
+ <input type="password" name="password" id="inputPassword" class="form-control" required>
172
177
173
178
<input type="hidden" name="_csrf_token"
174
179
value="{{ csrf_token('authenticate') }}"
@@ -300,7 +305,7 @@ a traditional HTML form that submits to ``/login``:
300
305
}
301
306
}
302
307
303
- **Step 4. ** Updates the main security config file to enable the Guard authenticator:
308
+ **Step 4. ** Updates the main security config file to enable the Guard authenticator and configure logout route :
304
309
305
310
.. configuration-block ::
306
311
@@ -316,6 +321,8 @@ a traditional HTML form that submits to ``/login``:
316
321
guard :
317
322
authenticators :
318
323
- App\Security\LoginFormAuthenticator
324
+ logout :
325
+ path : app_logout
319
326
320
327
.. code-block :: xml
321
328
0 commit comments