From 5744d77e707e8b7665526203065511126b439700 Mon Sep 17 00:00:00 2001 From: Olivier PARPAILLON Date: Tue, 19 Nov 2024 14:01:57 +0100 Subject: [PATCH] redirection good --- assets/styles/app.css | 18 ++++++++++++++++++ config/packages/security.yaml | 9 ++++----- src/Controller/LoginController.php | 4 ++++ templates/auth/login.html.twig | 4 ++-- templates/auth/register.html.twig | 8 ++++---- 5 files changed, 32 insertions(+), 11 deletions(-) diff --git a/assets/styles/app.css b/assets/styles/app.css index c328ce7..7aab00b 100644 --- a/assets/styles/app.css +++ b/assets/styles/app.css @@ -39,4 +39,22 @@ footer { .star.text-yellow-500 { color: gold; +} + +.bgRegisterText { + color: #333333; +} + +.bgRegister { + background-color: #A3D9B1; +} + +.btnRegister { + background-color: #FF6F61; + border-color: #C8504C; +} + +.btnRegister:hover { + background-color: rgb(218, 76, 93); + border-color: #FF6F61; } \ No newline at end of file diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 058188d..c7b078d 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -22,12 +22,10 @@ security: login_path: app_login check_path: app_login enable_csrf: true - default_target_path: home - always_use_default_target_path: true logout: path: app_logout + target: app_login # where to redirect after logout - # target: app_any_route # activate different ways to authenticate # https://symfony.com/doc/current/security.html#the-firewall @@ -38,8 +36,9 @@ security: # Easy way to control access for large sections of your site # Note: Only the *first* access control that matches will be used access_control: - # - { path: ^/admin, roles: ROLE_ADMIN } - # - { path: ^/profile, roles: ROLE_USER } + - { path: ^/login, roles: PUBLIC_ACCESS } + - { path: ^/register, roles: PUBLIC_ACCESS } + - { path: ^/, roles: ROLE_USER } when@test: security: diff --git a/src/Controller/LoginController.php b/src/Controller/LoginController.php index 5ff415e..0c53bd4 100644 --- a/src/Controller/LoginController.php +++ b/src/Controller/LoginController.php @@ -16,6 +16,10 @@ class LoginController extends AbstractController #[Route(path: '/login', name: 'app_login')] public function login(AuthenticationUtils $authenticationUtils, Security $security, Request $request): Response { + if ($security->isGranted('ROLE_USER')) { + return $this->redirectToRoute('home'); // Redirection pour utilisateurs connectés + } + // get the login error if there is one $error = $authenticationUtils->getLastAuthenticationError(); diff --git a/templates/auth/login.html.twig b/templates/auth/login.html.twig index d775802..efd1fc4 100644 --- a/templates/auth/login.html.twig +++ b/templates/auth/login.html.twig @@ -22,9 +22,9 @@ value="{{ csrf_token('authenticate') }}" >
- + - +
diff --git a/templates/auth/register.html.twig b/templates/auth/register.html.twig index 9e2b65f..2f7b132 100644 --- a/templates/auth/register.html.twig +++ b/templates/auth/register.html.twig @@ -11,9 +11,9 @@ {% block content %}
-
-

Sortir !

-

Bienvenue sur notre application web référencant tout type d'évènements à travers le monde. N'hésitez pas à vous inscrire sur notre plateforme et y invitez vos amis afins de participer à des évènements simplement et qui vous conviennent !

+
+

Sortir !

+

Bienvenue sur notre application web référencant tout type d'évènements à travers le monde. N'hésitez pas à vous inscrire sur notre plateforme et y invitez vos amis afins de participer à des évènements simplement et qui vous conviennent !

S'inscrire

@@ -23,7 +23,7 @@ {{ form_row(registrationForm.telephone) }} {{ form_row(registrationForm.email) }} {{ form_row(registrationForm.plainPassword) }} - + {{ form_end(registrationForm) }}