我試圖讓我的應用程序設置正確的哨兵軟件包。laravel哨兵重定向::打算不工作
我可以登錄用戶進出,並保護路線,但我似乎無法讓redirect::intended
正常工作。我的理解是,用戶在被引導到登錄頁面之前將被帶回他們最初呼叫的路線。目前它只是保持重定向到默認頁面。
在我的routes.php文件我有以下組設置:
Route::group(array('before' => 'sentryAuth'), function() {...}
在這一組中我已經放在所有受保護的途徑。
在我filters.php我有以下過濾器:
Route::filter('sentryAuth', function() {
if (!Sentry::check()) {
return Redirect::route('login');
}
});
路線::過濾器( 'sentryGuest',函數(){
if (Sentry::check()) {
return Redirect::intended('dashboard');
}
});
在我UserController中,我有以下代碼:
public function postAuthenticate()
{
try {
// Set login credentials
$credentials = array(
'email' => Input::get('email'),
'password' => Input::get('password')
);
// Try to authenticate the user
$user = Sentry::authenticate($credentials, false);
} catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
echo 'Login field is required.';
}
catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
echo 'Password field is required.';
}
catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
echo 'User was not found.';
}
catch (Cartalyst\Sentry\Users\WrongPasswordException $e) {
echo 'Wrong password, try again.';
}
catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) {
echo 'User is not activated.';
}
if (!Sentry::check()) {
return Redirect::to('user/login');
} else {
return Redirect::intended('dashboard');
}
}
我試圖訪問一個頁面'預訂/創建'而不登錄。我得到t o登錄頁面,登錄,但它然後帶我到儀表板不預訂/創建。
AM我在這裏錯過了什麼?有沒有額外的代碼,我需要得到預期的工作?
出色答卷 - 修改工作,併發生重定向如預期。謝謝 – Ray