我需要使用Laravel/Fortify以编程方式生成2FA密钥,但没有文档介绍如何做到这一点?
在我的User模型中,I am useing TwoFactorAuthenticable
class User extends Authenticatable
{
use TwoFactorAuthenticatable;并且在config/fortity.php中启用了TwoFactorAuthentication
'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();有没有人破解了怎么做?
发布于 2021-07-27 19:13:11
从我的用户控制器...
use Laravel\Fortify\Actions\EnableTwoFactorAuthentication;
// Add Two Factor Authentication to this User
if ($request->tfa) {
$tfa = \App::make('Laravel\Fortify\Contracts\TwoFactorAuthenticationProvider');
$enable = new EnableTwoFactorAuthentication($tfa);
$myrc = $enable($user);
}https://stackoverflow.com/questions/64339497
复制相似问题