<?php

namespace App\Controller;

use KnpU\OAuth2ClientBundle\Client\ClientRegistry;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;

class KeycloakController extends AbstractController
{
    #[Route('/connect/keycloak', name: 'connect_keycloak')]
    public function connect(ClientRegistry $clientRegistry): RedirectResponse
    {
        return $clientRegistry->getClient('keycloak')->redirect(['openid', 'email', 'profile'], []);
    }

    #[Route('/connect/keycloak/check', name: 'connect_keycloak_check')]
    public function check(): Response
    {
        // Ce controller ne sera jamais execute car le firewall intercepte la requete
        return new Response('', Response::HTTP_OK);
    }
}
