diff --git a/backend/config/packages/security.yaml b/backend/config/packages/security.yaml index 7e48cb5..704f0ca 100644 --- a/backend/config/packages/security.yaml +++ b/backend/config/packages/security.yaml @@ -19,8 +19,10 @@ security: custom_authenticator: App\Security\LoginAuthenticator logout: path: app_logout - # where to redirect after logout target: app_login + remember_me: + secret: '%kernel.secret%' + lifetime: 604800 # 1 week in seconds # activate different ways to authenticate # https://symfony.com/doc/current/security.html#the-firewall diff --git a/backend/src/Security/LoginAuthenticator.php b/backend/src/Security/LoginAuthenticator.php index 7a67118..75a30b1 100644 --- a/backend/src/Security/LoginAuthenticator.php +++ b/backend/src/Security/LoginAuthenticator.php @@ -10,6 +10,7 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Http\Authenticator\AbstractLoginFormAuthenticator; use Symfony\Component\Security\Http\Authenticator\Passport\Badge\CsrfTokenBadge; +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\PasswordCredentials; use Symfony\Component\Security\Http\Authenticator\Passport\Passport; @@ -35,6 +36,7 @@ public function authenticate(Request $request): Passport new UserBadge(userIdentifier: (string) $email), credentials: new PasswordCredentials(password: (string) $request->request->get(key: 'password', default: '')), badges: [ + new rememberMeBadge(), new CsrfTokenBadge(csrfTokenId: 'authenticate', csrfToken: (string) $request->request->get(key: '_csrf_token')), ] ); diff --git a/backend/templates/security/login.html.twig b/backend/templates/security/login.html.twig index 50453e9..00c804a 100644 --- a/backend/templates/security/login.html.twig +++ b/backend/templates/security/login.html.twig @@ -81,7 +81,7 @@
- {% set createdWeb = 2023 %} - {% set now = "now"|date("Y") %} - {{ createdWeb == now ? now : (createdWeb ~'-'~ now) }} - ·Tous droits réservés. Conçu par - - Papoel - -