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