class DashboardController extends BaseController {
protected $layout = "layouts.dashboard";
public function __construct(){
//$this->beforeFilter('csrf', array('on'=>'post'));
$this->beforeFilter('auth', array('only'=>array('getIndex')));
}
public function getIndex(){
$this->layout->content= View::make('dashboard.index');
}
}
上面给出的代码是我的仪表板控制器。当我登录并重定向到仪表板时没关系。当用户在仪表板中时,这意味着用户已通过身份验证。现在在网址栏中,我点击了登录网址。就我而言,它是
http://localhost:8000/users/login
现在,即使用户已登录,它也会重定向到登录。现在,当我想知道如果用户已登录,我们如何自动重定向到仪表板时。 我是 laravel 4.2 的新手。我希望你能指导我。我在本节中迷路了
您可以尝试将其放入getIndex()
函数中:
if(Session::has('login_parameters')) return Redirect::to('foo/dashboard');
我在 Laravel 3 中使用此代码,希望它也适用于 laravel 4.2。