<?php

namespace App\Filters;

use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Filters\FilterInterface;

class AuthCheck implements FilterInterface
{
    public function before(RequestInterface $request, $arguments = null)
    {
        $session = session();
        log_message('debug', 'URI PATH: ' . service('uri')->getPath());

        // 로그인 체크
        if (!$session->get('logged_in')) {
            // 로그인 안 되어 있으면 로그인 페이지로
            return redirect()->to('/login');
        }
    }

    public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
    {
        // After logic not required
    }
}



?>