question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot access current user in controller

See original GitHub issue

I’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:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
iwillhappy1314commented, Sep 27, 2016

Awesome! test ok!

1reaction
axyrcommented, Sep 2, 2016

https://github.com/laravel/framework/issues/15072

And a shitload of other tickets regarding this issue…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found