• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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 ?

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.