Я хочу перенаправить пользователя обратно на введенный URL-адрес после аутентификации пользователя. Сценарий: пользователь вводит URL-адрес, в бэкэнде я проверяю, аутентифицирован ли пользователь, и если пользователь не аутентифицирован, перенаправляю пользователя на URL-адрес входа и после успешного входа перенаправляю пользователя обратно на первый URL-адрес. этот пользователь ввел
Контроллер пользователей:
public function index()
{
if(!Auth::check())
{
return View::make('adminLogin');
}
return Redirect::to('admin');
}
public function login()
{
$creds = array(
'username' => Input::get('username'),
'password' => Input::get('password')
);
if (Auth::attempt($creds))
return Redirect::back();
}
маршруты.php:
Route::resource('users', 'UsersController');
Route::post('login', 'UsersController@login');
фильтры.php:
Route::filter('logged', function($request)
{
if(!Auth::check())
return Redirect::to('users');
});
НастройкаКонтроллер.php:
public function __construct()
{
$this->beforeFilter('logged', array('only' => array('index')));
}
public function index()
{
return View::make('setting');
}
Пожалуйста, помогите мне. Я новичок в Laravel.