route auth php laravel laravel-5 laravel-5.3

auth - route php



laravel 5.3 nuevo Auth:: routes() (7)

Recientemente empiezo a usar laravel 5.3 para escribir un blog, pero tengo una pregunta después de ejecutar php artisan make:auth

cuando ejecuto esto, generará rutas en mi web.php

Este es el código que contiene:

Auth::routes(); Route::get(''/home'', ''HomeController@index'');

Luego ejecuto php artisan route:list , encuentro muchas acciones, como LoginController @ login ...

Pero no encontré estas acciones en mi App/Http/Controllers/Auth , ¿dónde están?

Y también, qué significa Auth::routes() , no puedo encontrar las rutas sobre Auth.

Necesito ayuda de alguien, gracias por responder mi pregunta.


Aquí está Laravel 5.7 y Laravel 5.8 (sin cambios), incluidas las rutas de verificación , si desea incluirlas también.

// Authentication Routes... Route::get(''login'', ''Auth/LoginController@showLoginForm'')->name(''login''); Route::post(''login'', ''Auth/LoginController@login''); Route::post(''logout'', ''Auth/LoginController@logout'')->name(''logout''); // Registration Routes... Route::get(''register'', ''Auth/RegisterController@showRegistrationForm'')->name(''register''); Route::post(''register'', ''Auth/RegisterController@register''); // Password Reset Routes... Route::get(''password/reset'', ''Auth/ForgotPasswordController@showLinkRequestForm'')->name(''password.request''); Route::post(''password/email'', ''Auth/ForgotPasswordController@sendResetLinkEmail'')->name(''password.email''); Route::get(''password/reset/{token}'', ''Auth/ResetPasswordController@showResetForm'')->name(''password.reset''); Route::post(''password/reset'', ''Auth/ResetPasswordController@reset'')->name(''password.update''); // Email Verification Routes... Route::get(''email/verify'', ''Auth/VerificationController@show'')->name(''verification.notice''); Route::get(''email/verify/{id}'', ''Auth/VerificationController@verify'')->name(''verification.verify''); Route::get(''email/resend'', ''Auth/VerificationController@resend'')->name(''verification.resend'');

Puede verificar estas rutas aquí:


Esto funcionó para mí con Laravel 5.6 .

En el archivo web.php , simplemente reemplace:

Auth::routes();

Por:

//Auth::routes(); // Authentication Routes... Route::get(''admin/login'', ''Auth/LoginController@showLoginForm'')->name(''login''); Route::post(''admin/login'', ''Auth/LoginController@login''); Route::post(''admin/logout'', ''Auth/LoginController@logout'')->name(''logout''); // Password Reset Routes... Route::get(''password/reset'', ''Auth/ForgotPasswordController@showLinkRequestForm'')->name(''password.request''); Route::post(''password/email'', ''Auth/ForgotPasswordController@sendResetLinkEmail'')->name(''password.email''); Route::get(''password/reset/{token}'', ''Auth/ResetPasswordController@showResetForm'')->name(''password.reset''); Route::post(''password/reset'', ''Auth/ResetPasswordController@reset'');

Y elimine el enlace Registrarse en los dos archivos a continuación:

welcome.blade.php layouts/app.blade.php


Para Laravel 5.5.x

// 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'');


Rutas de autenticación para Laravel 5.3 en lugar de Auth :: routes (). Espero que ayude...

Route::group([''middleware'' => [''web'']], function() { // Login Routes... Route::get(''login'', [''as'' => ''login'', ''uses'' => ''Auth/LoginController@showLoginForm'']); Route::post(''login'', [''as'' => ''login.post'', ''uses'' => ''Auth/LoginController@login'']); Route::post(''logout'', [''as'' => ''logout'', ''uses'' => ''Auth/LoginController@logout'']); // Registration Routes... Route::get(''register'', [''as'' => ''register'', ''uses'' => ''Auth/RegisterController@showRegistrationForm'']); Route::post(''register'', [''as'' => ''register.post'', ''uses'' => ''Auth/RegisterController@register'']); // Password Reset Routes... Route::get(''password/reset'', [''as'' => ''password.reset'', ''uses'' => ''Auth/ForgotPasswordController@showLinkRequestForm'']); Route::post(''password/email'', [''as'' => ''password.email'', ''uses'' => ''Auth/ForgotPasswordController@sendResetLinkEmail'']); Route::get(''password/reset/{token}'', [''as'' => ''password.reset.token'', ''uses'' => ''Auth/ResetPasswordController@showResetForm'']); Route::post(''password/reset'', [''as'' => ''password.reset.post'', ''uses'' => ''Auth/ResetPasswordController@reset'']); });

Entonces, si cambia algunos nombres de estas rutas, recuerde también cambiar en las vistas las acciones de las publicaciones.



orden de llamada de función:

  1. (Auth) Illuminate / Support / Facades / Auth @ routes ( github.com/laravel/framework/blob/5.3/src/Illuminate/Support/… )
  2. (Aplicación) Illuminate / Foundation / Application @ auth
  3. (Ruta) Iluminar / Enrutamiento / Enrutador

es una ruta como esta:

public function auth() { // Authentication Routes... $this->get(''login'', ''Auth/AuthController@showLoginForm''); $this->post(''login'', ''Auth/AuthController@login''); $this->get(''logout'', ''Auth/AuthController@logout''); // Registration Routes... $this->get(''register'', ''Auth/AuthController@showRegistrationForm''); $this->post(''register'', ''Auth/AuthController@register''); // Password Reset Routes... $this->get(''password/reset/{token?}'', ''Auth/PasswordController@showResetForm''); $this->post(''password/email'', ''Auth/PasswordController@sendResetLinkEmail''); $this->post(''password/reset'', ''Auth/PasswordController@reset''); }


Auth::routes() es solo una clase auxiliar que le ayuda a generar todas las rutas necesarias para la autenticación del usuario. Puede buscar el código aquí https://github.com/laravel/framework/blob/5.3/src/Illuminate/Routing/Router.php lugar.

Aquí están las rutas.

// 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''); $this->post(''password/email'', ''Auth/ForgotPasswordController@sendResetLinkEmail''); $this->get(''password/reset/{token}'', ''Auth/ResetPasswordController@showResetForm''); $this->post(''password/reset'', ''Auth/ResetPasswordController@reset'');