Skip to content
Snippets Groups Projects
Commit 5910c320 authored by user's avatar user
Browse files

User V4

parent 7a4f89dd
Branches
No related tags found
No related merge requests found
...@@ -24,9 +24,9 @@ security: ...@@ -24,9 +24,9 @@ security:
remember_me: remember_me:
secret: '%kernel.secret%' secret: '%kernel.secret%'
# access_control: access_control:
# - { path: ^/admin, allow_if: "user and user.isAdmin == true" } - { path: ^/admin, allow_if: "user and user.isAdmin == true" }
# - { path: ^/locked, allow_if: "user and user.isLocked == true" } #- { path: ^/user, allow_if: "user and user.isLocked == false" }
when@test: when@test:
security: security:
......
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class HomeController extends AbstractController
{
#[Route('/', name: 'homepage')]
public function index(): Response
{
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'),
],
]);
}
}
\ 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, $user->getPassword()); $hashedPassword = $passwordHasher->hashPassword($user, $form->get('plainPassword')->getData());
$user->setPassword($hashedPassword); $user->setPassword($hashedPassword);
// Sauvegarder l'utilisateur // Sauvegarder l'utilisateur
......
...@@ -6,6 +6,8 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; ...@@ -6,6 +6,8 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Routing\Attribute\Route;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
final class UserController extends AbstractController final class UserController extends AbstractController
{ {
......
...@@ -5,11 +5,12 @@ namespace App\Entity; ...@@ -5,11 +5,12 @@ namespace App\Entity;
use App\Repository\UserRepository; use App\Repository\UserRepository;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
#[ORM\Entity(repositoryClass: UserRepository::class)] #[ORM\Entity(repositoryClass: UserRepository::class)]
class User implements UserInterface class User implements UserInterface, PasswordAuthenticatedUserInterface
{ {
private array $roles = []; private array $roles = [];
...@@ -34,7 +35,7 @@ class User implements UserInterface ...@@ -34,7 +35,7 @@ class User implements UserInterface
#[ORM\Column] #[ORM\Column]
private ?int $id = null; private ?int $id = null;
#[ORM\Column(length: 255)] #[ORM\Column(length: 255, unique: true)]
private ?string $email = null; private ?string $email = null;
#[ORM\Column(length: 63)] #[ORM\Column(length: 63)]
...@@ -46,11 +47,11 @@ class User implements UserInterface ...@@ -46,11 +47,11 @@ class User implements UserInterface
#[ORM\Column(length: 255)] #[ORM\Column(length: 255)]
private ?string $password = null; private ?string $password = null;
#[ORM\Column] #[ORM\Column(type: 'boolean', options: ['default' => false])]
private ?bool $isLocked = null; private ?bool $isLocked = false;
#[ORM\Column] #[ORM\Column(type: 'boolean', options: ['default' => false])]
private ?bool $isAdmin = null; private ?bool $isAdmin = false;
#[ORM\Column(length: 255, nullable: true)] #[ORM\Column(length: 255, nullable: true)]
private ?string $image = null; private ?string $image = null;
......
{% extends 'base.html.twig' %}
{% block title %}Homepage{% endblock %}
{% block body %}
<div class="container mt-5">
<h1>Welcome to the Wishlist Project</h1>
<p>Here are the main links to navigate through the project:</p>
<ul>
{% for label, url in links %}
<li><a href="{{ url }}">{{ label }}</a></li>
{% endfor %}
</ul>
</div>
{% endblock %}
\ No newline at end of file
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
</div> </div>
<div class="container"> <div class="container">
{% for wishlist in Wishlists %} {% for wishlist in wishlists %}
<div class="wishlist"> <div class="wishlist">
<h2>{{ wishlist.title }}</h2> <h2>{{ wishlist.title }}</h2>
<div class="wishlist-items"> <div class="wishlist-items">
...@@ -31,6 +31,6 @@ ...@@ -31,6 +31,6 @@
<button title="Delete wishlist">🗑</button> <button title="Delete wishlist">🗑</button>
</div> </div>
</div> </div>
{% end for %} {% endfor %}
</div> </div>
{% endblock %} {% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment