@@ -74,10 +74,15 @@ class that processes the login submit and 4) updates the main security config fi
7474 // last username entered by the user
7575 $lastUsername = $authenticationUtils->getLastUsername();
7676
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');
8186 }
8287
8388 /**
@@ -165,10 +170,10 @@ a traditional HTML form that submits to ``/login``:
165170 {% endif %}
166171
167172 <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>
172177
173178 <input type="hidden" name="_csrf_token"
174179 value="{{ csrf_token('authenticate') }}"
@@ -300,7 +305,7 @@ a traditional HTML form that submits to ``/login``:
300305 }
301306 }
302307
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 :
304309
305310.. configuration-block ::
306311
@@ -316,6 +321,8 @@ a traditional HTML form that submits to ``/login``:
316321 guard :
317322 authenticators :
318323 - App\Security\LoginFormAuthenticator
324+ logout :
325+ path : app_logout
319326
320327 .. code-block :: xml
321328
0 commit comments