Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Autenticar usuarios en Laravel 5 manualmente
<?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
}
$userData = \App\User::where('email',request('email'))->first();
if ($userData && \Hash::check(request('password'), $userData->password))
{
auth()->loginUsingId($userData->id);
//log que necesites
}
//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
You can’t perform that action at this time.