<?php
namespace App\Http\Controller\Auth;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class AuthController extends AbstractController
{
/**
* @Route("/user", name="user_login")
*/
public function loginPage(
AuthenticationUtils $authenticationUtils,
Request $request,
?UserInterface $user = null
): Response {
$request->getSession()->set('is_safari', $request->query->getBoolean('safari', false));
$request->getSession()->set('redirect-uri', $request->query->get('redirect-uri'));
if (null !== $user) {
if ($request->getSession()->get('is_safari')) {
return $this->redirectToRoute('user_login_succeed');
} elseif ($request->getSession()->get('redirect-uri')) {
// return $this->redirectToRoute('user_sessions_profile');
if ($request->getSession()->get('redirect-uri') == 'ios-login') {
return $this->redirectToRoute('user_ios_login_index');
}
return $this->redirect($request->getSession()->get('redirect-uri'));
}
return $this->redirectToRoute('user_sessions_index');
}
$error = $authenticationUtils->getLastAuthenticationError();
if ($request->getSession()->has('facebook_error')) {
$error = $request->getSession()->get('facebook_error');
}
return $this->render(
'user/auth/login.html.twig',
['error' => $error, 'last_username' => $authenticationUtils->getLastUsername()]
);
}
/**
* @Route("/logout", name="user_logout")
*/
public function logout(): \Symfony\Component\HttpFoundation\RedirectResponse
{
return $this->redirectToRoute('site_index');
}
/**
* @Route("/user/login-succeed", name="user_login_succeed")
*/
public function succeedLoginPage(): Response
{
return $this->render('user/auth/succeed_login.html.twig');
}
}