<?php

declare(strict_types=1);

namespace App\Controllers;

use App\Core\Controller;

final class AuthController extends Controller
{
    public function login(): string
    {
        return $this->view('auth/login', ['title' => 'Вход'], 'layouts/plain');
    }

    public function authenticate(): string
    {
        if ($response = $this->ensureCsrf()) {
            return $response;
        }

        $_SESSION['user_id'] = 1;

        return $this->redirect('/dashboard');
    }

    public function register(): string
    {
        return $this->view('auth/register', ['title' => 'Регистрация'], 'layouts/plain');
    }

    public function store(): string
    {
        if ($response = $this->ensureCsrf()) {
            return $response;
        }

        $_SESSION['user_id'] = 1;

        return $this->redirect('/dashboard');
    }

    public function forgotPassword(): string
    {
        return $this->view('auth/forgot', ['title' => 'Забравена парола'], 'layouts/plain');
    }

    public function verifyEmail(): string
    {
        return $this->view('auth/verify', ['title' => 'Потвърждение на имейл'], 'layouts/plain');
    }
}
