<?php
namespace App\Modules\Auth\Controllers;
use App\Core\{View, Security};
class AuthController
{
    public function index()
    {
        header('Location: ' . url('/auth/login'));
        exit;
    }
    public function login()
    {
        if (session_status() === PHP_SESSION_NONE)
            session_start();
        if ($_SERVER['REQUEST_METHOD'] === 'POST') {
            Security::checkCSRF();
            if ($_POST['email'] === 'admin@admin.com') {
                $_SESSION['user'] = 'Admin';
                header('Location: ' . url('/finance/index'));
                exit;
            }
        }
        View::render('Auth/Views/login');
    }
}