zend-blog-3-backend
32 строки · 817.0 Байт
1<?php
2
3namespace App\Controller;
4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
6use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
7use Symfony\Component\Routing\Annotation\Route;
8use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
9
10class SecurityController extends AbstractController
11{
12private AuthenticationUtils $authUtils;
13
14public function __construct(AuthenticationUtils $authUtils)
15{
16$this->authUtils = $authUtils;
17}
18
19/**
20* @Route("/login")
21* @Template()
22*
23* @return array
24*/
25public function loginAction(): array
26{
27$error = $this->authUtils->getLastAuthenticationError();
28$lastUsername = $this->authUtils->getLastUsername();
29
30return compact('error', 'lastUsername');
31}
32}
33