updrade with rector
This commit is contained in:
@@ -2,21 +2,44 @@
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use ApiPlatform\Core\Api\IriConverterInterface;
|
||||
use App\Entity\User;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Config\Definition\Exception\Exception;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class SecurityController extends AbstractController
|
||||
{
|
||||
#[Route(path: '/login', name: 'app_login')]
|
||||
public function login(AuthenticationUtils $authenticationUtils): Response
|
||||
#[Route(path: '/login', name: 'app_login')] // *** method post
|
||||
public function login(AuthenticationUtils $authenticationUtils, IriConverterInterface $iriConverter): Response
|
||||
{
|
||||
|
||||
if (!$this->isGranted(attribute: 'IS_AUTHENTICATED_FULLY')) {
|
||||
return $this->json(data: [
|
||||
'error' => 'Invalid login request'
|
||||
], status: 400);
|
||||
}
|
||||
|
||||
/** @var User $user */
|
||||
$user = $this->getUser() ?? null;
|
||||
|
||||
return new Response(content: null, status: 204, headers: [
|
||||
'Location' => $iriConverter->getIriFromItem(item: $user)
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
return $this->render(view: 'security/login.html.twig', parameters: [
|
||||
'error' => $authenticationUtils->getLastAuthenticationError(),
|
||||
'last_username' => $authenticationUtils->getLastUsername(),
|
||||
]);
|
||||
*
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user