<?php

namespace App\Filters;

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

class UserFilter implements FilterInterface
{
    public function before(RequestInterface $request, $arguments = null)
    {
        // Do something here
        if (auth()->loggedIn()) {
            $userdata = service('user_data');   
            if(!isset($userdata->data->username)){
                $userdata->GetUser();
            }
        }else{
            $userdata = service('user_data');
            $userdata->data = null;
        }
    }

    public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
    {
        // Do something here
        
    }
}
?>