src/Controller/SecurityController.php line 29

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\User;
  4. use Symfony\Component\HttpFoundation\Request;
  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. use Twig\Environment;
  10. class SecurityController extends AbstractController
  11. {
  12.     private $twig;
  13.     public function __construct(Environment $twig)
  14.     {
  15.         $this->twig $twig;
  16.     }
  17.     /**
  18.      * @Route("/login", name="app_login")
  19.      */
  20.     public function login(Request $requestAuthenticationUtils $authenticationUtils): Response
  21.     {
  22.         $error $authenticationUtils->getLastAuthenticationError();
  23.         $lastUsername $authenticationUtils->getLastUsername();
  24.         return $this->render('security/index.html.twig',
  25.             ['last_username' => $lastUsername'error' => $error]);
  26.     }
  27.     /**
  28.      * @Route("/logout", name="app_logout", methods={"GET"})
  29.      */
  30.     public function logout()
  31.     {
  32.     }
  33.     function changePass($id$pass$passwordEncoder)
  34.     {
  35.         $em $this->getDoctrine()->getManager();
  36.         $userId $em->getRepository(User::class)->find($id);
  37.         $userId->setPassword($passwordEncoder->hashPassword($userId$pass));
  38.         $em->flush();
  39.         return true;
  40.     }
  41. }