10000 minor #12802 Security: How to Build a Login Form: sync with recent Ma… · symfony/symfony-docs@fdf887f · GitHub
[go: up one dir, main page]

Skip to content

Commit fdf887f

Browse files
committed
minor #12802 Security: How to Build a Login Form: sync with recent Maker Bundle changes (mhujer)
This PR was submitted for the 5.0 branch but it was merged into the 4.4 branch instead. Discussion ---------- Security: How to Build a Login Form: sync with recent Maker Bundle changes Related to #11265 <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/roadmap for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `master` for features of unreleased versions). --> Commits ------- a4023d6 Security: How to Build a Login Form: sync with recent Maker Bundle changes
2 parents 3fc1646 + a4023d6 commit fdf887f

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

security/form_login_setup.rst

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)
0