<?php
namespace App\Controller\Admin;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
//登陆
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
#[Route('/admin', name: 'admin.')]
class SecurityController extends AbstractController
{
#[Route('/login', name: 'login', options: ['name'=>'登陆', 'ignore'=> true])]
public function login(AuthenticationUtils $authenticationUtils, Request $request)
{
$error = $authenticationUtils->getLastAuthenticationError();
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('admin/security/login.html.twig',[
'error' => $error,
'last_username' => $lastUsername,
]);
}
#[Route('/logout', name: 'logout', options: ['name'=>'退出', 'ignore'=> true])]
public function logout()
{
throw new \Exception('This method can be blank - it will be intercepted by the logout key on your firewall');
}
}