vendor/kobizo/core-bundle/src/Controller/FeSecurityController.php line 23

Open in your IDE?
  1. <?php
  2. namespace Kobizo\Bundle\CoreBundle\Controller;
  3. use Kobizo\Component\Attributes\DefaultRolesAttribute;
  4. use Kobizo\Component\Configuration\Google\GoogleCaptchaConfig;
  5. use Kobizo\Component\Configuration\Google\GoogleCaptchaPublicKeyConfig;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter;
  9. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  10. class FeSecurityController extends KobizoFeAbstractController
  11. {
  12.     /**
  13.      * @Route("/login", name="app_login")
  14.      */
  15.     public function login(
  16.         AuthenticationUtils $authenticationUtils,
  17.         GoogleCaptchaConfig $googleCaptchaConfig,
  18.         GoogleCaptchaPublicKeyConfig $googleCaptchaPublicKeyConfig
  19.     ): Response {
  20.         if ($this->isGranted(AuthenticatedVoter::IS_AUTHENTICATED_FULLY)
  21.             && $this->getUser()
  22.             && $this->isGranted(DefaultRolesAttribute::CLIENT)
  23.         ) {
  24.             return $this->redirectToRoute('customer_account', [], 302false);
  25.         }
  26.         // get the login error if there is one
  27.         $error $authenticationUtils->getLastAuthenticationError();
  28.         // last username entered by the user
  29.         $lastUsername $authenticationUtils->getLastUsername();
  30.         $googleCaptchaEnable $googleCaptchaConfig->isGoogleCaptchaEnabled();
  31.         return $this->render('@KobizoCore/frontend/login.twig', [
  32.             'last_username' => $lastUsername,
  33.             'error' => $error,
  34.             'isGoogleCaptchaEnabled' => $googleCaptchaEnable,
  35.             'captcha_public_key' => $googleCaptchaEnable $googleCaptchaPublicKeyConfig->getValue() : "",
  36.         ]);
  37.     }
  38.     /**
  39.      * @Route("/logout", name="app_logout")
  40.      */
  41.     public function logout()
  42.     {
  43.         return $this->redirectToRoute('home');
  44.     }
  45. }