当我登录时,它应该将我重定向到/photlight,但它没有。如果你没有登录,而你试图访问/聚光灯,它会重定向你登录。知道为什么吗?
http://pastebin.com/ERVAj2eu
在为聚光灯提供路由之前,您正在运行身份验证过滤器,因此必须检查用户是否已登录,如果未登录,则将其重定向到登录页面。
在登录路径中,您需要更改以下内容:
return Redirect::intended('/');
到此:
return Redirect::intended('/spotlight');
现在,登录后应重定向到聚光灯路由。
尝试
Redirect::route('spotlight');
并创建该路线
Route::get("/spotlight", array( "as" => "spotlight", "uses" => "Controller@function");
请重新编写您的"登录"路由,如下所示。根据您当前的逻辑,无论身份验证是否成功,您都会再次看到"登录"页面;您必须有一个else
子句,以便仅当身份验证失败时才重新加载login
页面:
Route::post('/login', function()
{
$credentials = Input::only('username', 'password');
if (Auth::attempt($credentials)) {
return Redirect::intended('/');
}
else
{
return Redirect::to('login');
}
});