Cannot access current user in controller
See original GitHub issueI’ve tried the following:
auth()->user();
Auth::user();
All of them are returning null. I’ve tried to add some middleware to the route group:
Route::group([
'prefix' => 'admin',
'middleware' => [
'auth',
'role:admin,access_backend'
]
], function () {
CRUD::resource('brands', 'Admin\BrandCrudController');
});
Am I missing something?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Cannot access "Current user" in rails - devise - Stack Overflow
The problem was that I had overridden the devise mapping and current_user. I removed them and was able to access current user in...
Read more >Migrate from ClaimsPrincipal.Current - Microsoft Learn
Learn how to migrate away from ClaimsPrincipal.Current to retrieve the current authenticated user's identity and claims in ASP.NET Core.
Read more >Symfony 5.4: How to get current user in a login controller?
How can I get the current user in a json login controller? For Symfony 5.4 the docs use: public function index(#[CurrentUser] ?
Read more >Authorization - Laravel - The PHP Framework For Web Artisans
If the action is not authorized or if no user is currently authenticated, Laravel will automatically throw an Illuminate\Auth\Access\AuthorizationException ...
Read more >Spring Security gets the currently logged in user
Either in stateful Session mode or in the popular JWT mode you can use SecurityContext to get the current user. 1 2, Authentication ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Awesome! test ok!
https://github.com/laravel/framework/issues/15072
And a shitload of other tickets regarding this issue…