使用 Auth::routes () 时,路由列表中没有 Email 认证相关路由

在 Laravel 6.4 中使用 Auth::routes () 时,路由列表中不包含 Email 认证相关路由
在 Laravel 6.4 中使用 Auth::routes() 时,路由中没有 Email 认证相关路由

《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
最佳答案

在 web.php 添加Auth::routes(['verify' => true]); 或者 Route::Auth(['verify'=>true]);
效果:

Laravel

6年前 评论
讨论数量: 3

我刚开始学习这个课程,你这个问题我也遇到了,但是我杠翻看了一下官方文档,希望为遇到相同困扰的同学解惑!

Laravel includes the Auth\VerificationController class that contains the necessary logic to send verification links and verify emails. To register the necessary routes for this controller, pass the verify option to the Auth::routes method: 这是原文,通俗一点就是需要开启路由,解决方法;

auth::routers( [ ' verify ' => ' true ' ] )

然后在使用!

php aritsan route:list

可以看到

+--------+----------+--------------------------+---------------------+------------------------------------------------------------------------+------------------------------+
| Domain | Method   | URI                      | Name                | Action                                                                 | Middleware                   |
+--------+----------+--------------------------+---------------------+------------------------------------------------------------------------+------------------------------+
|        | GET|HEAD | /                        |                     | Closure                                                                | web                          |
|        | GET|HEAD | api/user                 |                     | Closure                                                                | api,auth:api                 |
|        | POST     | email/resend             | verification.resend | App\Http\Controllers\Auth\VerificationController@resend                | web,auth,throttle:6,1        |
|        | GET|HEAD | email/verify             | verification.notice | App\Http\Controllers\Auth\VerificationController@show                  | web,auth                     |
|        | GET|HEAD | email/verify/{id}/{hash} | verification.verify | App\Http\Controllers\Auth\VerificationController@verify                | web,auth,signed,throttle:6,1 |
|        | GET|HEAD | home                     | home                | App\Http\Controllers\HomeController@index                              | web,auth                     |
|        | POST     | login                    |                     | App\Http\Controllers\Auth\LoginController@login                        | web,guest                    |
|        | GET|HEAD | login                    | login               | App\Http\Controllers\Auth\LoginController@showLoginForm                | web,guest                    |
|        | POST     | logout                   | logout              | App\Http\Controllers\Auth\LoginController@logout                       | web                          |
|        | POST     | password/confirm         |                     | App\Http\Controllers\Auth\ConfirmPasswordController@confirm            | web,auth                     |
|        | GET|HEAD | password/confirm         | password.confirm    | App\Http\Controllers\Auth\ConfirmPasswordController@showConfirmForm    | web,auth                     |
|        | POST     | password/email           | password.email      | App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail  | web                          |
|        | GET|HEAD | password/reset           | password.request    | App\Http\Controllers\Auth\ForgotPasswordController@showLinkRequestForm | web                          |
|        | POST     | password/reset           | password.update     | App\Http\Controllers\Auth\ResetPasswordController@reset                | web                          |
|        | GET|HEAD | password/reset/{token}   | password.reset      | App\Http\Controllers\Auth\ResetPasswordController@showResetForm        | web                          |
|        | POST     | register                 |                     | App\Http\Controllers\Auth\RegisterController@register                  | web,guest                    |
|        | GET|HEAD | register                 | register            | App\Http\Controllers\Auth\RegisterController@showRegistrationForm      | web,guest                    |
+--------+----------+--------------------------+---------------------+------------------------------------------------------------------------+------------------------------+
6年前 评论

在 web.php 添加Auth::routes(['verify' => true]); 或者 Route::Auth(['verify'=>true]);
效果:

Laravel

6年前 评论

刚好我也有这个疑问,看到这里,清晰了,不错

5年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!