! $request->is ('email/*', 'logout')

// 三个判断:
// 1. 如果用户已经登录
// 2. 并且还未认证 Email
// 3. 并且访问的不是 email 验证相关 URL 或者退出的 URL。
if ($request->user() && ! $request->user()->hasVerifiedEmail() && ! $request->is('email/*', 'logout')) {
前两个可以理解 ,3 请求的不是email/ 跟logout 。但是用户如果未验证将自动www.x.com/email/verify 也就是违反了 ! $request->is('email/', 'logout')) 所以这个写法是不是错误了! 或者说如何理解!

《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
最佳答案

不会违反,因为是如果不是email/*,就跳转到email/verify,而email/verifyemail/*,不会再跳转。

6年前 评论
李小明 (楼主) 6年前
李小明 (楼主) 6年前
讨论数量: 2

不会违反,因为是如果不是email/*,就跳转到email/verify,而email/verifyemail/*,不会再跳转。

6年前 评论
李小明 (楼主) 6年前
李小明 (楼主) 6年前

@maogu 如果在routes\web.php中这样写:

Auth::routes(['verify' => true]);

定位到routes方法的位置:vendor\laravel\framework\src\Illuminate\Support\Facades\Auth.php

public static function routes(array $options = [])
{
    static::$app->make('router')->auth($options);
}

实际上是auth方法,继续定位:
是在Illuminate\Routing\Router.php:

public function auth(array $options = []){...}

其中调用了:

public function emailVerification()
    {
        $this->get('email/verify', 'Auth\VerificationController@show')->name('verification.notice');
        $this->get('email/verify/{id}/{hash}', 'Auth\VerificationController@verify')->name('verification.verify');
        $this->post('email/resend', 'Auth\VerificationController@resend')->name('verification.resend');
    }

第一条就是那个路由。

6年前 评论

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