-
Notifications
You must be signed in to change notification settings - Fork 119
Open
Labels
bugSomething isn't workingSomething isn't working
Description
laravel upgraded 8 to 11, I'm getting $request→user() and Auth::user() null value in web route.
routes/web.php
Route::get('customer/{id}', [FrontendController::class, 'home']);
app/Http/Controllers/FrontendController.php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
public function home(Request $request)
{
dd($request->user(), Auth::user());
}
bootstrap/app.php
->withRouting(
web: __DIR__ . '/../routes/web.php',
api: [
__DIR__ . '/../routes/api/core.php',
__DIR__ . '/../routes/api/user.php'
],
commands: __DIR__ . '/../routes/console.php',
health: '/up'
)
->withMiddleware(function (Middleware $middleware) {
//dd($middleware->getMiddlewareGroups());
})
->withExceptions(function (Exceptions $exceptions) {
//
})->create();
Middleware groups showing when dd($middleware->getMiddlewareGroups())
"web" => [
0 => "Illuminate\Cookie\Middleware\EncryptCookies",
1 => "Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse",
2 => "Illuminate\Session\Middleware\StartSession",
3 => "Illuminate\View\Middleware\ShareErrorsFromSession",
4 => "Illuminate\Foundation\Http\Middleware\ValidateCsrfToken",
5 => "Illuminate\Routing\Middleware\SubstituteBindings",
],
"api" => [
0 => "Illuminate\Routing\Middleware\SubstituteBindings"
]
Config file
config/auth.php
'defaults' => [
'guard' => 'api',
'passwords' => 'users',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'jwt',
'provider' => 'users',
],
],
config/session.php
'driver' => 'file'
Your environment:
| Q | A |
|---|---|
| Bug? | no / yes |
| New Feature? | no / yes |
| Framework | Laravel / Lumen |
| Framework version | 11.x |
| Package version | 2.7 |
| PHP version | 8.2 |
Expected behaviour
$request->user() or Auth::user() should be a logged-in user in the controller.
Actual behaviour
$request->user() and Auth::user() both are getting null
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working