src/Controller/Utils/SecurityController.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Utils;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  8. use Symfony\Component\HttpFoundation\RedirectResponse;
  9. class SecurityController extends AbstractController {
  10.     /**
  11.      * @Route("/login", name="app_login")
  12.      */
  13.     public function login(Request $requestAuthenticationUtils $authenticationUtils): Response {
  14.         $ip $request->server->get('REMOTE_ADDR');
  15.         //dd($ip);
  16.         if ($_ENV['HOME_EXT_IP'] === $ip) { 
  17.             // turn of maintenance_mode if on local network
  18.             $_ENV['MAINTENANCE_MODE'] = '0';
  19.         }
  20.         // if ($this->getUser()) {
  21.         //     return $this->redirectToRoute('target_path');
  22.         // }
  23.         // get the login error if there is one
  24.         $error $authenticationUtils->getLastAuthenticationError();
  25.         // last username entered by the user
  26.         $lastUsername $authenticationUtils->getLastUsername();
  27.         return $this->render('security/login.html.twig', [
  28.                     'last_username' => $lastUsername,
  29.                     'error' => $error
  30.         ]);
  31.     }
  32.     /**
  33.      * @Route("/logout", name="app_logout")
  34.      */
  35.     public function logout() {
  36.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  37.     }
  38. }