Reputation: 105
Create the Route file from the Route Service Provide and assign the middleware "admin.auth" and this middleware working in the web.php giving the basic information of the admin user but from the custom.php it is returning auth false. How can admin.auth will work from route service provider
protected function mapWebRoutes2()
{
Route::group([
'namespace' => $this->namespace,
'prefix' => 'custom',
'middleware' => 'admin.auth'
], function ($router) {
require base_path('routes/custom.php');
});
}
Upvotes: 3
Views: 1053
Reputation: 8252
Make sure to include the web
middleware, otherwise the default authentication won't work since the session etc. is not started:
protected function mapWebRoutes2()
{
Route::group([
'namespace' => $this->namespace,
'prefix' => 'custom',
'middleware' => ['web', 'admin.auth']
], function () {
require base_path('routes/custom.php');
});
}
or shorter:
protected function mapWebRoutes2()
{
Route::prefix('custom')
->middleware(['web', 'admin.auth'])
->namespace($this->namespace)
->group(base_path('routes/custom.php'));
}
Upvotes: 3
Reputation: 7111
Try with copy of existing example for api routes. In your example something like:
/**
* Define the "custom" routes for the application.
*
* @return void
*/
protected function mapWebRoutes2()
{
Route::prefix('custom')
->middleware(['admin.auth'])
->namespace($this->namespace)
->group(base_path('routes/custom.php'));
}
Upvotes: 0