Welcome Guest, Not a member yet? Register   Sign In
CI4: Pass Data From Filter to Controller

Is there anyway to pass authenticated user data from filter to controller?

You can add anything to the Request and it will be available in your controller at $this->request. I think it would be more typical however to have some middleware library that handles the authentication state, and is accessed by both your Filter and Controller. So for example your Filter uses App\Libraries\Authentication::login() and then Controller uses App\Libraries\Authentication::getUser()

In my case, it's a rest api with just jwt token with no username or password. In the filter, the user id will be decoded from the token and need to pass to controller. How to modify $this->request ?

Theme © iAndrew 2016 - Forum software by © MyBB