Created
January 9, 2018 11:03
-
-
Save uno-de-piera/e1c771c537a0dadf0d0987c5ed3f6cf7 to your computer and use it in GitHub Desktop.
Autenticar usuarios en Laravel 5 manualmente con Auth::attempt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Route::post('login', function() { | |
$validator = \Validator::make(request()->all(), [ | |
'email' => 'required', | |
'password' => 'required' | |
]); | |
if ($validator->fails()) { | |
//mostrar errores, o en json o lo que necesites | |
} | |
if (\Auth::attempt(['email' => request('email'), 'password' => request('password')])) { | |
return redirect()->intended('¿?')); | |
} | |
//si estás aquí algo ha salido mal, 404, 401, 403?? | |
})->middleware('guest'); //sólo para invitados! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment