src\Controller\SigninController.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Controller\AppController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\HttpFoundation\JsonResponse;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use App\Service\ApiCalls;
  9. use App\Security\AppAuthenticator;
  10. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  11. use App\Security\PasscodeAuthenticator;
  12. class SigninController extends AppController
  13. {
  14.     
  15.     public function index(Request $HttpApiCalls $ApiCallsAuthenticationUtils $authenticationUtilsPasscodeAuthenticator $PasscodeAuthenticator$state=NULL): Response
  16.     {        
  17.         $check $this->commonCalls(['getFooter','getHomeNav','getSearch']); 
  18.         
  19.         if(!$check){
  20.             return $check;
  21.         }
  22.         
  23.         if($this->RedirectHandle!==NULL){
  24.             return $this->RedirectHandle;
  25.         }
  26.         
  27.         $redirectTo 'index';
  28.         
  29.         
  30.         if($state!==NULL){
  31.             $this->setData('state'$state);
  32.         }
  33.         
  34.         if(!$this->getUser()){
  35.             $error $authenticationUtils->getLastAuthenticationError();
  36.             if($error !==NULL){
  37.                 $this->setData('authError'$error['message']);
  38.             }
  39.             // last username entered by the user
  40.             $lastUsername $authenticationUtils->getLastUsername();
  41.             $this->setData('last_username'$lastUsername);
  42.             if($this->getUser()===NULL){
  43.                 return $this->render('signin/index.html.twig'
  44.                     $this->getData()
  45.                 );
  46.             }
  47.             else{
  48.                 return $this->redirectToRoute($redirectTo);
  49.             }
  50.         }
  51.         else{
  52.             return $this->redirectToRoute($redirectTo);
  53.         }
  54.     }
  55.     
  56.     public function isSignedIn(){
  57.         if(!$this->getUser()){
  58.            $response = new JsonResponse(['isSignedIn' => FALSE]);
  59.         }
  60.         else{
  61.             $response = new JsonResponse(['isSignedIn' => TRUE]);
  62.         }
  63.         return $response;
  64.     }
  65. }