This commit is contained in:
Jérémy Guillot
2024-06-03 17:36:22 +02:00
commit bddcdd6823
73 changed files with 13150 additions and 0 deletions

0
src/Controller/.gitignore vendored Normal file
View File

View File

@@ -0,0 +1,37 @@
<?php
namespace App\Controller;
use ApiPlatform\Api\IriConverterInterface;
use App\Entity\User;
use Exception;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\CurrentUser;
class SecurityController extends AbstractController
{
#[Route('/login', name: 'app_login', methods: ['GET', 'POST'])]
public function login(IriConverterInterface $iriConverter, #[CurrentUser] User $user = null): Response
{
if(!$user){
return $this->json([
'error' => 'Invalid credentials'
], 401);
}
return new Response(null, 204, [
'Location' => $iriConverter->getIriFromResource($user),
]);
}
/**
* @throws Exception
*/
#[Route('/logout', name: 'app_logout', methods: ['GET'])]
public function logout(): void
{
throw new Exception('This method can be blank.');
}
}