dingo / dingo/api

Internal Requests - Access authenticated user outside of controller

Open
#1,256 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
9.4k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

Hi,

I'm using Dingo's Internal Requests, specifying which user to authenticate as (API::be($user)), and this works well for Dingo's auth middleware as well as for my controllers... but I cannot access the user info anywhere outside of the controller as far as I can tell.

I need to access the user in both a middleware and a model observer. I've tried Auth::user(), request()->user(), $request->user(), etc, but it all returns null. These all return the user when making a regular request through a Dingo API route, just not when spoofing the user through the Internal Requests dispatcher.

Any thoughts? For clarification, I'm using Dingo's built-in jwt.auth support for authentication.

Thanks.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.