api-guard
api-guard copied to clipboard
$this->user Null
Hello guys,
I use to be working with the version 2.
I'm now starting a new project with 3.1.1. My controllers extend ApiController and ApiController itself extends ApiGuardController.
The key validation is working just fine, what I can't seem to get working is the $this->user. it seems to always be null.
Regards,
Morgan
Hi @morganzysman is the api_key associated with a user_id? What auth library are you using?
Hello, yes it is associated with a user_id.
I'm not using any auth library
Regards
I'm having the same problem, keeps coming up with null. It appears that it's authorising the user once $this->auth->onceUsingId($id) but actually you're trying to retrieve the user from the $auth object a second time when you try and access it from the controller. @chrisbjr I could be wrong but I'm guessing a fix would be to save the user as a property in the singleton ApiGuardAuth class, instead of accessing it numerous times from the $auth object. Otherwise @morganzysman without modifying the library, you can access the user from the Illuminate\Http\Request instance
I created a pull request for this issue: #143