Skip to content

Commit

Permalink
Generate data-controller="csrf-protection" on CSRF fields
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Jan 6, 2025
1 parent 0624f13 commit b13f0fb
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 16 deletions.
5 changes: 1 addition & 4 deletions templates/authenticator/login_form.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
<input type="<?= $username_is_email ? 'email' : 'text'; ?>" value="{{ last_username }}" name="<?= $username_field; ?>" id="input<?= ucfirst($username_field); ?>" class="form-control" autocomplete="<?= $username_is_email ? 'email' : 'username'; ?>" required autofocus>
<label for="inputPassword">Password</label>
<input type="password" name="password" id="inputPassword" class="form-control" autocomplete="current-password" required>

<input type="hidden" name="_csrf_token"
value="{{ csrf_token('authenticate') }}"
>
<input type="hidden" name="_csrf_token" data-controller="csrf-protection" value="{{ csrf_token('authenticate') }}">
<?php if($support_remember_me && !$always_remember_me): ?>

<div class="checkbox mb-3">
Expand Down
5 changes: 1 addition & 4 deletions templates/security/formLogin/login_form.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
<input type="<?= $username_is_email ? 'email' : 'text'; ?>" value="{{ last_username }}" name="_username" id="username" class="form-control" autocomplete="<?= $username_is_email ? 'email' : 'username'; ?>" required autofocus>
<label for="password">Password</label>
<input type="password" name="_password" id="password" class="form-control" autocomplete="current-password" required>

<input type="hidden" name="_csrf_token"
value="{{ csrf_token('authenticate') }}"
>
<input type="hidden" name="_csrf_token" data-controller="csrf-protection" value="{{ csrf_token('authenticate') }}">

{#
Uncomment this section and add a remember_me option below your firewall to activate remember me functionality.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
<input type="email" value="{{ last_username }}" name="_username" id="username" class="form-control" autocomplete="email" required autofocus>
<label for="password">Password</label>
<input type="password" name="_password" id="password" class="form-control" autocomplete="current-password" required>

<input type="hidden" name="_csrf_token"
value="{{ csrf_token('authenticate') }}"
>
<input type="hidden" name="_csrf_token" data-controller="csrf-protection" value="{{ csrf_token('authenticate') }}">

{#
Uncomment this section and add a remember_me option below your firewall to activate remember me functionality.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
<input type="email" value="{{ last_username }}" name="_username" id="username" class="form-control" autocomplete="email" required autofocus>
<label for="password">Password</label>
<input type="password" name="_password" id="password" class="form-control" autocomplete="current-password" required>

<input type="hidden" name="_csrf_token"
value="{{ csrf_token('authenticate') }}"
>
<input type="hidden" name="_csrf_token" data-controller="csrf-protection" value="{{ csrf_token('authenticate') }}">

{#
Uncomment this section and add a remember_me option below your firewall to activate remember me functionality.
Expand Down

0 comments on commit b13f0fb

Please sign in to comment.