Advertisement
wemersonrv

Autenticação usando somente Routes

Nov 28th, 2012
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. Route::group(array('before' => 'auth'), function(){
  2.     Route::controller(Controller::detect());
  3. });
  4.  
  5.  
  6. Route::get('login', function(){
  7.     return View::make('dashboard.login');
  8. });
  9.  
  10. Route::post('login', function(){
  11.     $userinfo = array(
  12.         'username' => Input::get('login'),
  13.         'password' => Input::get('senha')
  14.     );
  15.  
  16.     if(Auth::attempt($userinfo))
  17.         return Redirect::to('/');
  18.     else
  19.         return Redirect::to('login')
  20.             ->with('login_errors', true);
  21. });
  22.  
  23. Route::get('logout', function(){
  24.     Auth::logout();
  25.     return Redirect::to('/');
  26. });
  27.  
  28. Route::filter('auth', function()
  29. {
  30.     if (Auth::guest()) {
  31.         return Redirect::to('login');
  32.     }
  33. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement