Laravel Jetstream 是为 Laravel 设计的精美的应用程序脚手架。Jetstream 为你的下一个项目提供了完美的起点,包括登录、注册、电子邮件验证、双因子认证、会话管理、通过 Laravel Sanctum 提供的 API 支持以及可选的团队管理。Laravel Jetstream 替代并改进了可用于早期版本的 Laravel 的旧式身份验证 UI 支架。

默认情况下Laravel Jetstream并没有开启电子邮件验证功能,如果我们需要实现邮件验证,那么需要手动开启,步骤如下:

1.打开config/fortify.php文件,找到’features‘配置项,取消对’emailVerification‘的注释。


'features' => [
    Features::registration(),
    Features::resetPasswords(),
    Features::emailVerification(),//取消对该项的注释
    Features::updateProfileInformation(),
    Features::updatePasswords(),
    Features::twoFactorAuthentication([
        'confirmPassword' => true,
    ]),
],

2.修改app/Models/User.php,继承‘MustVerifyEmail’接口。


class User extends Authenticatable implements MustVerifyEmail

再次访问user/profile会出现验证邮件提示: