【发布时间】:2019-08-21 00:03:51
【问题描述】:
我希望创建一个路由组,使特定用户无需经过身份验证即可查看我网站上的信息。
目前,我创建了一个名为“public”的路由服务提供商,如下所示:
Route::get('customer/application', function () {
return view('customerview.customer-application');
});
当我写 'php artisan route:list' 时,路线会出现以下内容:
方法:GET |头 URL:客户/应用程序 中间件:''
我已删除所有中间件以试图绕过身份验证,但没有成功。
将我重定向到登录页面的区域在 App\Exceptions\Handler.php 中:
protected function unauthenticated($request, AuthenticationException $exception)
{
if ($request->expectsJson()) {
return response()->json(['error' => 'Unauthenticated.'], 401);
}
return redirect()->guest('login');
}
我也尝试将路线分配给“访客”组,但没有帮助。如何绕过不同组的返回redirect()->guest('login');?
【问题讨论】:
-
你能提供你的路由文件吗?因为如果您不对任何组应用中间件或身份验证检查,未经身份验证的用户将可以看到它,我假设您已将
Auth::routes()放在路由文件中的任何组之外。 -
检查你的 RouteServiceProvider.php 可能是你在那里添加中间件。
-
在定义这条路线之前,您是否打电话给
Route::auth()?
标签: php laravel laravel-5 routes