Autenticación de usuarios con sesiones

Autenticación de Laravel

php artisan make:auth

Dentro de routes/web.api se añadió el conjunto de rutas

Auth::routes();

las cuales se encuentran en detalle dentro de vendor/laravel/framework/src/Iluminate/Routing/Router.php dentro del método auth

// Authentication Routes...
$this->get('login', 'Auth\LoginController@showLoginForm')->name('login');
$this->post('login', 'Auth\LoginController@login');
$this->post('logout', 'Auth\LoginController@logout')->name('logout');

// Registration Routes...
$this->get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
$this->post('register', 'Auth\RegisterController@register');

// Password Reset Routes...
$this->get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
$this->post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
$this->get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
$this->post('password/reset', 'Auth\ResetPasswordController@reset');

Para poder personalizar algunos detalles, reemplazamos Auth::routes() por la lista, dentro del archivo web.api.

Añadir ruta para la que no se necesita estar autenticado

CSRF Token

TokenMismatchException

Personalizar excepciones para formato web y para api

En el handler poder determinar cuando una petición viene desde el frontend:

Utilizar isFrontend() en los demás métodos del handler

Last updated

Was this helpful?