src/Http/Controller/Auth/AuthController.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Http\Controller\Auth;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  9. class AuthController extends AbstractController
  10. {
  11.     /**
  12.      * @Route("/user", name="user_login")
  13.      */
  14.     public function loginPage(
  15.         AuthenticationUtils $authenticationUtils,
  16.         Request $request,
  17.         ?UserInterface $user null
  18.     ): Response {
  19.         $request->getSession()->set('is_safari'$request->query->getBoolean('safari'false));
  20.         $request->getSession()->set('redirect-uri'$request->query->get('redirect-uri'));
  21.         if (null !== $user) {
  22.             if ($request->getSession()->get('is_safari')) {
  23.                 return $this->redirectToRoute('user_login_succeed');
  24.             } elseif ($request->getSession()->get('redirect-uri')) {
  25.                 // return $this->redirectToRoute('user_sessions_profile');
  26.                 if ($request->getSession()->get('redirect-uri') == 'ios-login') {
  27.                     return $this->redirectToRoute('user_ios_login_index');
  28.                 }
  29.                 return $this->redirect($request->getSession()->get('redirect-uri'));
  30.             }
  31.             return $this->redirectToRoute('user_sessions_index');
  32.         }
  33.         $error $authenticationUtils->getLastAuthenticationError();
  34.         if ($request->getSession()->has('facebook_error')) {
  35.             $error $request->getSession()->get('facebook_error');
  36.         }
  37.         return $this->render(
  38.             'user/auth/login.html.twig',
  39.             ['error' => $error'last_username' => $authenticationUtils->getLastUsername()]
  40.         );
  41.     }
  42.     /**
  43.      * @Route("/logout", name="user_logout")
  44.      */
  45.     public function logout(): \Symfony\Component\HttpFoundation\RedirectResponse
  46.     {
  47.         return $this->redirectToRoute('site_index');
  48.     }
  49.     /**
  50.      * @Route("/user/login-succeed", name="user_login_succeed")
  51.      */
  52.     public function succeedLoginPage(): Response
  53.     {
  54.         return $this->render('user/auth/succeed_login.html.twig');
  55.     }
  56. }