When taking the following store method on a lumen controller
public function store(Request $request, JwtToken $jwtToken, Redirector $redirector)
{
$sessionData = $request->session()->all();
$this->validate($request, [
'username' => 'required',
'password' => 'required'
]);
}
In $sessionData all the data in the session is present including the previous url. When going through the default validator it calls app('session')->previousUrl()
which returns null
When doing the same on $request->session()
it is present. I have no clue if I messed something up or this is a bug in lumen.
I tried Redis and File driver.
Seems to be a bug in Lumen fixed by doing the following
public function store(Request $request, JwtToken $jwtToken)
{
$sessionData = $request->session()->all();
$this->validate($request, [
'username' => 'required',
'password' => 'required'
]);
//use global redirect helper function
}
Removed the Redirector reference and used the global helper function
You forget this on your bootstrap/app.php
:
/*
|--------------------------------------------------------------------------
| Register Middleware
|--------------------------------------------------------------------------
|
| Next, we will register the middleware with the application. These can
| be global middleware that run before and after each request into a
| route or middleware that'll be assigned to some specific routes.
|
*/
$app->middleware([
Illuminate\Cookie\Middleware\EncryptCookies::class,
Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
Illuminate\Session\Middleware\StartSession::class,
Illuminate\View\Middleware\ShareErrorsFromSession::class,
Laravel\Lumen\Http\Middleware\VerifyCsrfToken::class,
]);