如何在 Laravel 中使用 Fortify 仅用于 2FA 和 Passport?

问题描述 投票:0回答:0

我有一个 Laravel 9 项目,我使用 Passport 进行身份验证。我不使用视图,因为前端是用 Vue 开发的。

现在我应该包括 2FA,我在 Laravel 文档中找到了 Fortify。使用起来似乎很简单,但是当我向 Fortify 端点发出请求时,响应是:

会话存储未按要求设置

这是我的 fortify.php 文件

//other code

'guard' => 'api',

//other code

'home' => '',

//other code

'views' => false, //I don't need Fortify views, I'll use only consuming API

//other code

'features' => [
    Features::twoFactorAuthentication([
        'confirmPassword' => true
    ]),
],

//other code

当我设置

confirmPassword
为false时,请求响应为200,DB中的2FA字段被填充(我还没有测试完整的周期,因为我需要确认密码,所以我想首先解决这个问题)。

所以,快速总结一下:我在 Laravel 9 中使用 Passport 进行身份验证。我需要 Fortify for 2FA 而无需其视图,仅通过使用 API。什么可能导致该错误?

laravel laravel-passport fortify two-factor-authentication
© www.soinside.com 2019 - 2024. All rights reserved.