<?php

namespace App\Controllers;

class Auth extends BaseController
{
    public function login()
    {
        return view('auth/login');
    }

    public function doLogin()
    {
        $email = $this->request->getPost('email');
        $password = $this->request->getPost('password');

        // Validasi Hardcoded
        if ($email === 'admin123@gmail.com' && $password === 'admin123') {
            // Set session jika perlu (untuk sementara skip session setup kompleks)
            session()->set('isLoggedIn', true);
            return redirect()->to('/admin');
        } else {
            return redirect()->back()->with('error', 'Email atau Password salah!');
        }
    }

    public function logout()
    {
        session()->destroy();
        return redirect()->to('/');
    }
}
