diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 7c33053..1a0e784 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -26,6 +26,7 @@ security: form_login: login_path: app_login check_path: app_login + default_target_path: app_index enable_csrf: true logout: path: app_logout @@ -37,6 +38,7 @@ security: form_login: login_path: app_login check_path: app_login + default_target_path: app_index enable_csrf: true logout: path: app_logout @@ -49,10 +51,16 @@ security: # https://symfony.com/doc/current/security/impersonating_user.html # switch_user: true + role_hierarchy: + ROLE_ADMIN: [ ROLE_ADMIN, ROLE_EMPLOYEE, ROLE_USER ] + ROLE_EMPLOYEE: ROLE_EMPLOYEE + ROLE_USER: ROLE_USER # 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: ^/login, roles: PUBLIC_ACCESS } + - { path: ^/register, roles: PUBLIC_ACCESS } + - { path: ^/, roles: IS_AUTHENTICATED_FULLY } # - { path: ^/profile, roles: ROLE_USER } when@test: @@ -66,4 +74,4 @@ when@test: algorithm: auto cost: 4 # Lowest possible value for bcrypt time_cost: 3 # Lowest possible value for argon - memory_cost: 10 # Lowest possible value for argon + memory_cost: 10 # Lowest possible value for argon \ No newline at end of file diff --git a/src/Controller/EmployeeController.php b/src/Controller/EmployeeController.php index 6e096c7..f0b853b 100644 --- a/src/Controller/EmployeeController.php +++ b/src/Controller/EmployeeController.php @@ -22,26 +22,6 @@ final class EmployeeController extends AbstractController ]); } - #[Route('/new', name: 'app_employee_new', methods: ['GET', 'POST'])] - public function new(Request $request, EntityManagerInterface $entityManager): Response - { - $employee = new Employee(); - $form = $this->createForm(EmployeeType::class, $employee); - $form->handleRequest($request); - - if ($form->isSubmitted() && $form->isValid()) { - $entityManager->persist($employee); - $entityManager->flush(); - - return $this->redirectToRoute('app_employee_index', [], Response::HTTP_SEE_OTHER); - } - - return $this->render('employee/new.html.twig', [ - 'employee' => $employee, - 'form' => $form, - ]); - } - #[Route('/{id}', name: 'app_employee_show', methods: ['GET'])] public function show(Employee $employee): Response { diff --git a/src/Controller/IndexController.php b/src/Controller/IndexController.php index c1ad21b..356aa94 100644 --- a/src/Controller/IndexController.php +++ b/src/Controller/IndexController.php @@ -2,6 +2,7 @@ namespace App\Controller; +use App\Entity\UserApp; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; @@ -11,7 +12,9 @@ class IndexController extends AbstractController #[Route('/index', name: 'app_index')] public function index(): Response { - return $this->render('index/index.html.twig', []); + return $this->render('index/index.html.twig', [ + 'id' => $this->getUser()->getId(), + ]); } #[Route('/test', name: 'app_test')] diff --git a/src/Controller/InternController.php b/src/Controller/InternController.php index fd4063d..f1de7d0 100644 --- a/src/Controller/InternController.php +++ b/src/Controller/InternController.php @@ -22,26 +22,6 @@ final class InternController extends AbstractController ]); } - #[Route('/new', name: 'app_intern_new', methods: ['GET', 'POST'])] - public function new(Request $request, EntityManagerInterface $entityManager): Response - { - $intern = new Intern(); - $form = $this->createForm(InternType::class, $intern); - $form->handleRequest($request); - - if ($form->isSubmitted() && $form->isValid()) { - $entityManager->persist($intern); - $entityManager->flush(); - - return $this->redirectToRoute('app_intern_index', [], Response::HTTP_SEE_OTHER); - } - - return $this->render('intern/new.html.twig', [ - 'intern' => $intern, - 'form' => $form, - ]); - } - #[Route('/{id}', name: 'app_intern_show', methods: ['GET'])] public function show(Intern $intern): Response { diff --git a/src/Controller/UserAppController.php b/src/Controller/UserAppController.php index f6e8161..7af1863 100644 --- a/src/Controller/UserAppController.php +++ b/src/Controller/UserAppController.php @@ -11,7 +11,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; -#[Route('/user/app')] +#[Route('/user')] final class UserAppController extends AbstractController { #[Route(name: 'app_user_app_index', methods: ['GET'])] @@ -22,26 +22,6 @@ final class UserAppController extends AbstractController ]); } - #[Route('/new', name: 'app_user_app_new', methods: ['GET', 'POST'])] - public function new(Request $request, EntityManagerInterface $entityManager): Response - { - $userApp = new UserApp(); - $form = $this->createForm(UserAppType::class, $userApp); - $form->handleRequest($request); - - if ($form->isSubmitted() && $form->isValid()) { - $entityManager->persist($userApp); - $entityManager->flush(); - - return $this->redirectToRoute('app_user_app_index', [], Response::HTTP_SEE_OTHER); - } - - return $this->render('user_app/new.html.twig', [ - 'user_app' => $userApp, - 'form' => $form, - ]); - } - #[Route('/{id}', name: 'app_user_app_show', methods: ['GET'])] public function show(UserApp $userApp): Response { diff --git a/src/Entity/UserApp.php b/src/Entity/UserApp.php index 7dabaa2..517c83e 100644 --- a/src/Entity/UserApp.php +++ b/src/Entity/UserApp.php @@ -52,9 +52,6 @@ class UserApp implements UserInterface, PasswordAuthenticatedUserInterface #[ORM\Column(length: 255,nullable: true)] private ?string $mail = null; - #[ORM\Column(nullable: true)] - private bool $isVerified = false; - public function getId(): ?int { return $this->id; diff --git a/src/Form/RegistrationFormType.php b/src/Form/RegistrationFormType.php index 012084f..a45fe3c 100644 --- a/src/Form/RegistrationFormType.php +++ b/src/Form/RegistrationFormType.php @@ -44,14 +44,7 @@ class RegistrationFormType extends AbstractType new NotBlank(), ] ]) -// ->add('agreeTerms', CheckboxType::class, [ -// 'mapped' => false, -// 'constraints' => [ -// new IsTrue([ -// 'message' => 'Vous devez accepter les conditions d\'utilisation.', -// ]), -// ], -// ]) +// ->add('plainPassword', PasswordType::class, [ // instead of being set onto the object directly, // this is read and encoded in the controller diff --git a/templates/announcement/list.html.twig b/templates/announcement/list.html.twig index 50912d2..541caaa 100644 --- a/templates/announcement/list.html.twig +++ b/templates/announcement/list.html.twig @@ -15,7 +15,7 @@

{{ ann.description }}

------------------------------ -

{{ ann.creationDate|format("d-m-y") }}

+

{{ ann.creationDate|date("d-m-y") }}

{% endfor %} diff --git a/templates/base.html.twig b/templates/base.html.twig index 80c70db..2fd436e 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -23,13 +23,13 @@
- HegreSphere + HegreSphere
-