Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel强化-如何生成双因素密钥?_Laravel - Fatal编程技术网

Laravel强化-如何生成双因素密钥?

Laravel强化-如何生成双因素密钥?,laravel,Laravel,我需要使用编程生成一个2FA密钥,但是没有关于如何生成的文档 在我的用户车型上,我是使用ingtwo-factorauthenticable class User extends Authenticatable { use TwoFactorAuthenticatable; 在config/fortity.php 'features' => [ Features::twoFactorAuthentication([ 'confirmPassword' =&

我需要使用编程生成一个2FA密钥,但是没有关于如何生成的文档

在我的
用户
车型上,我是
使用
ing
two-factorauthenticable

class User extends Authenticatable
{
    use TwoFactorAuthenticatable;
config/fortity.php

'features' => [
    Features::twoFactorAuthentication([
        'confirmPassword' => true,
    ]),
],
我尝试过以下功能:

// returns a "Call to undefined method" exception
$user->generateSecretKey();

// returns Decrypt error, presumably won't work without a secret set
$user->twoFactorQrCodeUrl();
$user->twoFactorQrCodeSvg();

有人破解了怎么做吗?

经过进一步挖掘,我在
vendors/laravel/fortify/src/Http/Controllers
中发现了
two-factorauthenticationcontroller
,它实际上在
store()
函数中有一个示例

当我在我的
UserObserver
中使用它时,它会起作用,如下所示:

use Laravel\Fortify\Actions\EnableTwoFactorAuthentication;

class UserObserver
{
    public function created(User $user, EnableTwoFactorAuthentication $enable)
    {
        $enable($user);
        ...