From 5934dfcdf54fce3c2d763c73f6ddf50efb117c90 Mon Sep 17 00:00:00 2001 From: barillote Date: Thu, 28 Nov 2024 17:15:33 +0100 Subject: [PATCH] pb login --- config/packages/security.yaml | 2 +- src/Controller/IndexController.php | 5 +- src/Controller/UserAppController.php | 40 ++++++------ templates/base.html.twig | 4 +- templates/security/login.html.twig | 4 +- templates/user_app/_delete_form.html.twig | 2 +- templates/user_app/show.html.twig | 76 ++++++++++------------- 7 files changed, 63 insertions(+), 70 deletions(-) diff --git a/config/packages/security.yaml b/config/packages/security.yaml index dfae12e..6704c77 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -50,7 +50,7 @@ security: # switch_user: true role_hierarchy: - ROLE_ADMIN: ROLE_ADMIN + 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 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/UserAppController.php b/src/Controller/UserAppController.php index f6e8161..7a74e73 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,25 +22,25 @@ 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('/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/templates/base.html.twig b/templates/base.html.twig index 80c70db..dca9b2b 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -31,11 +31,13 @@ À propos de nous Nous contacter + {% if app.user %}
- + Profil
+ {% endif %} diff --git a/templates/security/login.html.twig b/templates/security/login.html.twig index fb7733c..ca74689 100644 --- a/templates/security/login.html.twig +++ b/templates/security/login.html.twig @@ -8,9 +8,9 @@

Connexion

Pas encore inscrit ? Inscrivez vous !!
- En tant que Stagiaire + En tant que stagiaire
- En tant qu'Entreprise + En tant qu'entreprise

diff --git a/templates/user_app/_delete_form.html.twig b/templates/user_app/_delete_form.html.twig index 804fbbf..80d2260 100644 --- a/templates/user_app/_delete_form.html.twig +++ b/templates/user_app/_delete_form.html.twig @@ -1,4 +1,4 @@ - +
diff --git a/templates/user_app/show.html.twig b/templates/user_app/show.html.twig index 931539c..dc681df 100644 --- a/templates/user_app/show.html.twig +++ b/templates/user_app/show.html.twig @@ -3,52 +3,40 @@ {% block title %}UserApp{% endblock %} {% block body %} -

UserApp

+
+
+

Nom d'utilisateur :

+

{{ user_app.nickname }}

+
+
+

Rôles :

+

{{ user_app.roles ? user_app.roles|json_encode : '' }}

+
+
+

Prénom :

+

{{ user_app.firstName }}

+
+
+

Nom :

+

{{ user_app.lastName }}

+
+
+

Téléphone :

+

{{ user_app.tel }}

+
+
+

Addresse :

+

{{ user_app.address }}

+
+
+

Mail :

+

{{ user_app.mail }}

+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Id{{ user_app.id }}
Nickname{{ user_app.nickname }}
Roles{{ user_app.roles ? user_app.roles|json_encode : '' }}
Password{{ user_app.password }}
FirstName{{ user_app.firstName }}
LastName{{ user_app.lastName }}
Tel{{ user_app.tel }}
Address{{ user_app.address }}
Mail{{ user_app.mail }}
+ Modifier - back to list + {{ include('user_app/_delete_form.html.twig') }} +
- edit - {{ include('user_app/_delete_form.html.twig') }} {% endblock %}