Fix Remember me (#111)

This commit is contained in:
2026-05-21 21:38:31 +02:00
committed by GitHub
parent 182353e2eb
commit 03425024fe
4 changed files with 27 additions and 31 deletions
View File
+3
View File
@@ -24,6 +24,9 @@ security:
default_target_path: tvdt_backoffice_index
logout:
path: tvdt_login_logout
remember_me:
secret: '%kernel.secret%'
lifetime: 604800 # 1 week in seconds
access_control:
- { path: ^/admin, roles: ROLE_ADMIN }
-1
View File
@@ -8,7 +8,6 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use Symfony\Contracts\Translation\TranslatorInterface;
use Tvdt\Enum\FlashType;
+23 -29
View File
@@ -3,39 +3,33 @@
{% block title %}Log in{% endblock %}
{% block body %}
{% if app.user %}
<form method="post">
<h1 class="py-2 h3 mb-3 font-weight-normal">{{ 'Please sign in'|trans }}</h1>
<div class="mb-3">
You are logged in as {{ app.user.userIdentifier }}, <a href="{{ path('tvdt_login_logout') }}">Logout</a>
<label for="username" class="form-label">{{ 'Email'|trans }}</label>
<input type="email" value="{{ last_username }}" name="_username" id="username" class="form-control"
autocomplete="email" required autofocus>
</div>
{% else %}
<form method="post">
<h1 class="py-2 h3 mb-3 font-weight-normal">{{ 'Please sign in'|trans }}</h1>
<div class="mb-3">
<label for="username" class="form-label">{{ 'Email'|trans }}</label>
<input type="email" value="{{ last_username }}" name="_username" id="username" class="form-control"
autocomplete="email" required autofocus>
</div>
<div class="mb-3">
<label for="password" class="form-label">{{ 'Password'|trans }}</label>
<input type="password" name="_password" id="password" class="form-control"
autocomplete="current-password"
required>
</div>
<div class="mb-3">
<label for="password" class="form-label">{{ 'Password'|trans }}</label>
<input type="password" name="_password" id="password" class="form-control"
autocomplete="current-password"
required>
</div>
<input type="hidden" name="_csrf_token" data-controller="csrf-protection"
value="{{ csrf_token('authenticate') }}">
<input type="hidden" name="_csrf_token" data-controller="csrf-protection"
value="{{ csrf_token('authenticate') }}">
<div class="mb-3 form-check">
<input type="checkbox" name="_remember_me" id="_remember_me" class="form-check-input">
<label for="_remember_me" class="form-check-label">{{ 'Remember me'|trans }}</label>
</div>
<div class="mb-3 form-check">
<input type="checkbox" name="_remember_me" id="_remember_me" class="form-check-input" checked>
<label for="_remember_me" class="form-check-label">{{ 'Remember me'|trans }}</label>
</div>
<button class="btn btn-lg btn-primary" type="submit">
{{ 'Sign in'|trans }}
</button>
<a href="{{ path('tvdt_register') }}"
class="btn btn-link">{{ 'Create an account'|trans }}</a>
</form>
{% endif %}
<button class="btn btn-lg btn-primary" type="submit">
{{ 'Sign in'|trans }}
</button>
<a href="{{ path('tvdt_register') }}"
class="btn btn-link">{{ 'Create an account'|trans }}</a>
</form>
{% endblock %}