<?php

namespace App\Controller;

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

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

    #[Route('/connection/sso/logout', name: 'app_oauth_keycloak_logout')]
    public function logout(): RedirectResponse
    {
        return $this->redirectToRoute('app_home');
    }

    /**
     * @codeCoverageIgnore Handled by KeycloakAuthenticator
     */
    #[Route('/connection/sso/check', name: 'app_oauth_keycloak_check')]
    public function check(): void
    {
    }
}
