Tôi muốn người dùng khách có quyền truy cập vào trang chủ nhưng trong quá trình xác thực được xây dựng trong quá trình chuyển hướng laravel đến trang đăng nhập. làm thế nào tôi có thể cung cấp cho người dùng khách truy cập vào trang chủ?tắt phần mềm trung gian trên web cho các tuyến đường cụ thể trong laravel 5.2
routes.php tôi:
Route::group(['middleware' => 'web'], function() {
Route::auth();
Route::get('/', '[email protected]');
Route::get('/insert', '[email protected]');
Route::get('/job/{id}', '[email protected]');
Route::get('/city/{city}', '[email protected]');
Route::post('/insert', '[email protected]');
Route::get('/cityinsert', '[email protected]');
Route::post('/cityinsert', '[email protected]');
});
và authenticate.php
class Authenticate
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('login');
}
}
return $next($request);
}
}
và đây là kernel.php tôi
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array
*/
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
];
/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
],
'api' => [
'throttle:60,1',
],
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
];
}
hiển thị kernel .php cũng –
Tôi đã thêm tập tin hạt nhân –