getUser(); if (!$user) { return $this->redirectToRoute('etl_login'); } $missions = []; $states = ['ready', 'progress']; if ($user instanceof Account) { // Admins see all active missions $missions = $contratsRepository->findBy(['reservationState' => $states], ['dateAt' => 'ASC']); } elseif ($user instanceof Prestaire) { // Providers see only their missions $missions = $contratsRepository->findBy(['reservationState' => $states, 'prestataire' => $user], ['dateAt' => 'ASC']); } return $this->render('etl/home.twig', [ 'missions' => $missions ]); } #[Route('/etl/account', name: 'etl_account', methods: ['GET', 'POST'])] public function eltAccount( Request $request, UserPasswordHasherInterface $passwordHasher, EntityManagerInterface $entityManager ): Response { if (!$this->getUser()) { return $this->redirectToRoute('etl_login'); } $user = $this->getUser(); $form = $this->createForm(PrestairePasswordType::class, $user); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $hashedPassword = $passwordHasher->hashPassword( $user, $form->get('password')->getData() ); $user->setPassword($hashedPassword); $entityManager->flush(); $this->addFlash('success', 'Votre mot de passe a été modifié avec succès.'); return $this->redirectToRoute('etl_account'); } return $this->render('etl/account.twig', [ 'form' => $form->createView(), ]); } #[Route('/etl/connexion', name: 'etl_login')] public function eltLogin(AuthenticationUtils $authenticationUtils): Response { if ($this->getUser()) { return $this->redirectToRoute('etl_home'); } return $this->render('etl/login.twig', [ 'last_username' => $authenticationUtils->getLastUsername(), 'error' => $authenticationUtils->getLastAuthenticationError() ]); } #[Route('/etl/logout', name: 'elt_logout')] public function eltLogout(): Response { // This method can be blank - it will be intercepted by the logout key on your firewall return $this->redirectToRoute('etl_login'); } #[Route('/etl/connect/keycloak', name: 'connect_keycloak_etl_start')] public function connectKeycloakEtlStart(ClientRegistry $clientRegistry): RedirectResponse { return $clientRegistry ->getClient('keycloak_etl') ->redirect(['openid', 'profile', 'email']); } #[Route('/etl/oauth/sso', name: 'connect_keycloak_etl_check')] public function connectKeycloakEtlCheck(): Response { return new Response('Auth check', 200); // Intercepted by authenticator } }