I have an idea of โโlogging into the account, then the controller is called, where the data is verified and then saved using the authentication method.
public function doLogin(){ $rules = array( 'email' => 'required|email', 'password' => 'required' ); $validator = Validator::make(Input::all(), $rules); //dd(Input::all()); if($validator->fails()){ return Redirect::to('usuarios')->withErrors($validator)->withInput(Input::except('password')); }else{ $userdata = array( 'email' => Input::get('email'), 'password' => Input::get('password') ); if(Auth::attempt($userdata)){ return View::make('principal'); }else{ return Redirect::to('usuarios'); } } }
I also have a logout function
Route::get('usuarios/logout', function(){ Auth::logout(); return Redirect::to('usuarios');
The problem is that when I click the back button of the browser, I can use the application without problems, but without authentication.
Route
Route::get('usuarios', function(){ return View::make('login'); })->before('guest'); Route::get('usuarios/view', function(){ $usuarios = Usuario::paginate(5); return View::make('viewusuario', array('usuarios' => $usuarios)); })->before('auth'); Route::get('usuario/create', function(){ return View::make('formusuario'); })->before('auth');
Filter
Route::filter('auth', function() { if (Auth::guest()) return Redirect::guest('usuarios'); //login page }); Route::filter('guest', function() { if (Auth::check()){ return View::make('principal'); //home page } });
How can i fix this?
source share