现在我们让auth控制器为一系列预定义的路由提供了一些方法,我们希望我们的用户能够实际能够访问这些路由。 我们可以手动将所有路由添加到routes/web.php,但是已经有一个方便的工具,叫做Auth::routes()
// routes/web.php
Auth::routes();
Example 9-5. The routes provided by Auth::routes()
// 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');
// If email verification is enabled
$this->get('email/verify', 'Auth\VerificationController@show')
->name('verification.notice');
$this->get('email/verify/{id}', 'Auth\VerificationController@verify')
->name('verification.verify');
$this->get('email/resend', 'Auth\VerificationController@resend')
->name('verification.resend');
要启用Laravel的电子邮件验证服务,该服务要求新用户验证他们是否可以访问他们注册的电子邮件地址,请更新您的Auth::routes()调用以启用它,如此处所示。
Auth::routes(['verify' => true]);
在Laravel 5.7+,您可以给Auth::routes()方法传递“register” 和 “reset”键数组来信用注册和重置密码
Auth::routes(['register' => false, 'reset' => false]);