<?php

declare(strict_types=1);

namespace App\Modules\Identity\Controllers;

use App\Modules\Identity\Services\AuthService;

class LoginController
{
    public function __construct(private readonly AuthService $authService)
    {
    }

    public function show(): array
    {
        return [
            'view' => 'auth.login',
            'data' => [
                'title' => 'Anmeldung',
                'providers' => $this->authService->availableProviders(),
                'loginPreview' => $this->authService->centralLoginPreview(),
            ],
        ];
    }

    public function authenticate(array $payload): array
    {
        return $this->authService->attemptLogin($payload);
    }
}
