Skip to content
Snippets Groups Projects
Commit 1ebb2491 authored by mounouar21's avatar mounouar21
Browse files
parents 6134c969 2fae05af
No related branches found
No related tags found
No related merge requests found
...@@ -25,8 +25,10 @@ security: ...@@ -25,8 +25,10 @@ security:
secret: '%kernel.secret%' secret: '%kernel.secret%'
access_control: access_control:
# Allow access to /login without being authenticated # Allow access to /login and / without being authenticated
- { path: ^/login, allow_if: "1" } - { path: ^/login, allow_if: "1" }
- { path: ^/register, allow_if: "1" }
- { path: ^/$, allow_if: "1" }
# Allow users who are admins to access the /admin path # Allow users who are admins to access the /admin path
- { path: ^/admin, allow_if: "user and user.isAdmin() == true" } - { path: ^/admin, allow_if: "user and user.isAdmin() == true" }
...@@ -34,8 +36,7 @@ security: ...@@ -34,8 +36,7 @@ security:
# Allow users who are not locked to access other pages # Allow users who are not locked to access other pages
- { path: ^/.*, allow_if: "user and user.isLocked() != true" } - { 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: when@test:
security: security:
......
...@@ -11,15 +11,30 @@ class HomeController extends AbstractController ...@@ -11,15 +11,30 @@ class HomeController extends AbstractController
#[Route('/', name: 'homepage')] #[Route('/', name: 'homepage')]
public function index(): Response 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', [ return $this->render('home/index.html.twig', [
'links' => [ 'links' => $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'),
],
]); ]);
} }
} }
\ No newline at end of file
...@@ -22,7 +22,7 @@ class RegistrationController extends AbstractController ...@@ -22,7 +22,7 @@ class RegistrationController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
// Hacher le mot de passe // 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); $user->setPassword($hashedPassword);
// Sauvegarder l'utilisateur // Sauvegarder l'utilisateur
......
...@@ -3,7 +3,61 @@ ...@@ -3,7 +3,61 @@
{% block title %}Homepage{% endblock %} {% block title %}Homepage{% endblock %}
{% block body %} {% 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> <h1>Welcome to the Wishlist Project</h1>
<p>Here are the main links to navigate through the project:</p> <p>Here are the main links to navigate through the project:</p>
<ul> <ul>
...@@ -12,4 +66,18 @@ ...@@ -12,4 +66,18 @@
{% endfor %} {% endfor %}
</ul> </ul>
</div> </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 %}
...@@ -11,9 +11,7 @@ ...@@ -11,9 +11,7 @@
<input type="text" class="search-bar" placeholder="Search..."> <input type="text" class="search-bar" placeholder="Search...">
</header> </header>
<div class="navbar"> <a href="{{ path('app_wishlist_new') }}" class="add-wishlist-btn">Add wishlist</a> </div>
<button class="add-wishlist-btn">Add wishlist</button>
</div>
<div class="container"> <div class="container">
{% for wishlist in wishlists %} {% for wishlist in wishlists %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment