<?php

namespace App\Controllers;

use App\Modules\Auth\Services\AuthService;
use CodeIgniter\HTTP\ResponseInterface;

/**
 * Login Page Controller
 *
 * GET /login shows form; form submits to /api/auth/login (client-side).
 */
class LoginController extends BaseController
{
    public function index(): ResponseInterface
    {
        $authService = new AuthService();
        if ($authService->currentUser() !== null) {
            return redirect()->to('/dashboard');
        }

        return $this->response->setBody(view('login/index'));
    }
}
