diff --git a/config/packages/security.yaml b/config/packages/security.yaml index e8608e366d558d2bfd380de1419fb0a6242e437c..6910e77dfff51a77345d976573e08d0cb94fd825 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -25,8 +25,10 @@ security: secret: '%kernel.secret%' access_control: - # Allow access to /login without being authenticated + # Allow access to /login and / without being authenticated - { path: ^/login, allow_if: "1" } + - { path: ^/register, allow_if: "1" } + - { path: ^/$, allow_if: "1" } # Allow users who are admins to access the /admin path - { path: ^/admin, allow_if: "user and user.isAdmin() == true" } @@ -34,8 +36,7 @@ security: # Allow users who are not locked to access other pages - { path: ^/.*, allow_if: "user and user.isLocked() != true" } - # Allow all authenticated users to access other routes (outside /admin or /login) - - { path: ^/, allow_if: "user" } + when@test: security: diff --git a/src/Controller/HomeController.php b/src/Controller/HomeController.php index 8967bd5f668ce2797499102ddae4c220248bd328..b046743b1d974ea203baec3d3e5f6a2c5b82b855 100644 --- a/src/Controller/HomeController.php +++ b/src/Controller/HomeController.php @@ -11,15 +11,30 @@ class HomeController extends AbstractController #[Route('/', name: 'homepage')] public function index(): Response { + $user = $this->getUser(); // Récupère l'utilisateur connecté + + $links = [ + ]; + + // Ajoutez le lien "Admin Dashboard" uniquement si l'utilisateur est admin + if ($user && $user->isAdmin()) { + $links['Admin Dashboard'] = $this->generateUrl('admin_dashboard'); + } + + if (!$user) { + $links['Register'] = $this->generateUrl('register'); + $links['Login'] = $this->generateUrl('login'); + } + + if ($user) { + $links['My Wishlists'] = $this->generateUrl('app_wishlist_index'); + $links['Profile'] = $this->generateUrl('user_profile'); + $links['Logout'] = $this->generateUrl('logout'); + + } + return $this->render('home/index.html.twig', [ - 'links' => [ - 'Register' => $this->generateUrl('register'), - 'Login' => $this->generateUrl('login'), - 'My Wishlists' => $this->generateUrl('app_wishlist_index'), - 'Admin Dashboard' => $this->generateUrl('admin_dashboard'), - 'Profile' => $this->generateUrl('user_profile'), - - ], + 'links' => $links, ]); } } \ No newline at end of file diff --git a/src/Controller/RegistrationController.php b/src/Controller/RegistrationController.php index 96c886026eb60f8b33d73c21731544c9b58c09a7..84f8c732dcb1eb6f3430e4c0a6f8d11973f332d6 100644 --- a/src/Controller/RegistrationController.php +++ b/src/Controller/RegistrationController.php @@ -22,7 +22,7 @@ class RegistrationController extends AbstractController if ($form->isSubmitted() && $form->isValid()) { // Hacher le mot de passe - $hashedPassword = $passwordHasher->hashPassword($user, plainPassword: $form->get('plainPassword')->getData()); + $hashedPassword = $passwordHasher->hashPassword($user, plainPassword: $form->get('password')->getData()); $user->setPassword($hashedPassword); // Sauvegarder l'utilisateur diff --git a/templates/home/index.html.twig b/templates/home/index.html.twig index c54658099b28dc9694277438e16e5df6408315ab..3e984d3547fba0cb1420cfc147d8ca6246eafac0 100644 --- a/templates/home/index.html.twig +++ b/templates/home/index.html.twig @@ -3,7 +3,61 @@ {% block title %}Homepage{% endblock %} {% block body %} -<div class="container mt-5"> +<style> + body { + font-family: Arial, sans-serif; + background: linear-gradient(135deg, #00B8DE, #99CC33) fixed; + color: white; + text-align: center; + padding: 20px; + margin: 0; + height: 100vh; + display: flex; + align-items: center; + justify-content: center; + } + .container { + width: 90%; + max-width: 600px; + background: rgba(255, 255, 255, 0.2); + padding: 20px; + border-radius: 15px; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); + backdrop-filter: blur(10px); + } + h1 { + font-size: 2em; + margin-bottom: 10px; + } + p { + font-size: 1.2em; + } + ul { + list-style: none; + padding: 0; + } + li { + margin: 15px 0; + } + a { + text-decoration: none; + background: white; + padding: 10px 15px; + border-radius: 8px; + color: #00B8DE; + font-weight: bold; + transition: 0.3s; + display: inline-block; + margin: 10px; + } + a:hover { + background: #99CC33; + color: white; + transform: scale(1.1); + } +</style> + +<div class="container"> <h1>Welcome to the Wishlist Project</h1> <p>Here are the main links to navigate through the project:</p> <ul> @@ -12,4 +66,18 @@ {% endfor %} </ul> </div> -{% endblock %} \ No newline at end of file + +<script> + document.addEventListener("DOMContentLoaded", function() { + const links = document.querySelectorAll("a"); + links.forEach(link => { + link.addEventListener("mouseover", () => { + link.style.boxShadow = "0px 4px 15px rgba(255, 255, 255, 0.5)"; + }); + link.addEventListener("mouseout", () => { + link.style.boxShadow = "none"; + }); + }); + }); +</script> +{% endblock %} diff --git a/templates/wishlist/index.html.twig b/templates/wishlist/index.html.twig index f08571c4e46059f76d4f5d78d8fa32345f995300..ae0d2ce908f91c0f1e5ecb800ab2f53767c8b1a2 100644 --- a/templates/wishlist/index.html.twig +++ b/templates/wishlist/index.html.twig @@ -11,9 +11,7 @@ <input type="text" class="search-bar" placeholder="Search..."> </header> - <div class="navbar"> - <button class="add-wishlist-btn">Add wishlist</button> - </div> + <a href="{{ path('app_wishlist_new') }}" class="add-wishlist-btn">Add wishlist</a> </div> <div class="container"> {% for wishlist in wishlists %}