Guest User

Untitled

a guest
Jan 18th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. Route::get('admin/login', 'adminLoginController@showLogin'); // Mostrar login
  2. Route::post('admin/login', 'adminLoginController@postLogin'); // Verificar datos
  3. Route::get('admin/logout', 'adminLoginController@logOut'); // Finalizar sesión
  4.  
  5. Route::group(['before' => 'auth'], function()
  6. {
  7. Route::get('admin', function (){
  8.  
  9. });
  10. });
  11.  
  12. namespace AppHttpControllersadmin;
  13.  
  14. use IlluminateHttpRequest;
  15. use AppHttpControllersController;
  16. use DB;
  17. use Auth;
  18. use IlluminateSupportFacadesInput;
  19.  
  20. class LoginController extends Controller{
  21.  
  22. public function showLogin (){
  23.  
  24. if (Auth::check()){
  25. return Redirect::to('/admin');
  26. }
  27. return view('admin/login');
  28. }
  29.  
  30. public function postLogin(){
  31.  
  32. $data = [
  33. 'username' => Input::get('username'),
  34. 'password' => Input::get('password')
  35. ];
  36.  
  37. if (Auth::attempt($data, Input::get('remember')))
  38. {
  39.  
  40. return Redirect::intended('admin');
  41. }
  42.  
  43. return Redirect::back()->with('error_message', 'Invalid data')->withInput();
  44. }
  45.  
  46. public function logOut(){
  47. Auth::logout();
  48. return Redirect::to('admin/login')->with('error_message', 'Logged out correctly');
  49. }
  50. }
Add Comment
Please, Sign In to add comment