Skip to content

Commit

Permalink
Restore remember-me function
Browse files Browse the repository at this point in the history
  • Loading branch information
samwilson authored Dec 1, 2022
1 parent b2b6d07 commit 332620e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
5 changes: 4 additions & 1 deletion src/Security/LoginFormAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Symfony\Component\Security\Csrf\CsrfToken;
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
use Symfony\Component\Security\Http\Authenticator\AbstractLoginFormAuthenticator;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\RememberMeBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\CustomCredentials;
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
Expand Down Expand Up @@ -102,7 +103,9 @@ function ($credentials, User $user) {
return $validPassword && $twoFA;
},
$credentials
));
), [
new RememberMeBadge(),
]);
}

public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response
Expand Down
2 changes: 1 addition & 1 deletion templates/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<li>Logged in as {{ app.user.username }}</li>
<li><a href="{{ path('logout') }}">Log out</a></li>
{% else %}
<li><a href="{{ path('login') }}">Login</a></li>
<li><a href="{{ path('login') }}">{{'security.log_in'|trans}}</a></li>
{% endif %}
</ul>
</nav>
Expand Down
20 changes: 7 additions & 13 deletions templates/security/login.html.twig
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{% extends 'base.html.twig' %}

{% block title %}Log in{% endblock %}
{% block title %}{{'security.log_in'|trans}}{% endblock %}

{% block body %}

<h1>Log in</h1>
<h1>{{'security.log_in'|trans}}</h1>

<form class="login" method="post">

Expand All @@ -29,23 +29,17 @@
</p>
<p>
<span class="field size-1">
<input type="checkbox" id="remember-me" name="_remember_me" />
<label for="remember-me">Remember me</label>
<input type="checkbox" id="remember-me" name="_remember_me" checked />
<label for="remember-me">{{'security.remember_me'|trans}}</label>
</span>
</p>

<p>
<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}">
<span class="field size-1">
<input type="submit" value="Log in" />
</span>
<span class="field size-1">
<a class="button" href="{{ path('reset') }}">Reset password</a>
</span>
<input type="submit" value="Log in" />
<a class="button" href="{{ path('reset') }}">Reset password</a>
{% if user_registrations %}
<span class="field size-1">
<a class="button" href="{{ path('register') }}">Register</a>
</span>
<a class="button" href="{{ path('register') }}">Register</a>
{% endif %}
</p>
</form>
Expand Down
3 changes: 3 additions & 0 deletions translations/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ forms:
save: Save
cancel: Cancel
delete: Delete
security:
log_in: 'Log in'
remember_me: 'Remember me'
posts:
replies: 'Replies'
save_tooltip: 'Save the full version of this file'
Expand Down

0 comments on commit 332620e

Please sign in to comment.