src/Controller/DefaultController.php line 31

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Controller\Api\Service\ProfilerService;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\JsonResponse;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. final class DefaultController extends AbstractController
  10. {
  11.     public const INITIAL_ROUTE 'dashboard';
  12.     public const LOGIN_ROUTE 'app_login';
  13.     /**
  14.      * @Route("/test", name="app_test" )
  15.      */
  16.     public function test ():JsonResponse
  17.     {
  18.         return $this->json([
  19.             "message" => "Success",
  20.             "session" => $this->getUser()->getUserIdentifier()
  21.         ], Response::HTTP_OK );
  22.     }
  23.     /**
  24.      * @Route("/{react_routing}", priority="-1", name="indexs", defaults={"react_routing": null}, methods={"POST", "GET"}, requirements={"react_routing"=".+"})
  25.      */
  26.     public function index():Response
  27.     {
  28.         return $this->render('base.html.twig');
  29.     }
  30.     /**
  31.      * Layout login same path AuthController/login (api_auth_login_v2)
  32.      * @Route("/login", name="app_login")
  33.      * @param ProfilerService $profilerService
  34.      * @return Response
  35.      */
  36.     public function login(ProfilerService $profilerService): Response{
  37.         if(!is_null($profilerService->authenticated())){
  38.             if($url $profilerService->redirectToLastVisited()){
  39.                 return $this->redirect($url);
  40.             }
  41.             return $this->redirectToRoute(self::INITIAL_ROUTE);
  42.         }
  43.         return $this->render('security/index.html.twig');
  44.     }
  45.     /**
  46.      * Layout logout same path AuthController/logout (api_auth_logout)
  47.      * @Route("/logout", name="app_logout")
  48.      */
  49.     public function logout(): Response
  50.     {
  51.         return $this->redirectToRoute('app_login');
  52.     }
  53. }