This commit is contained in:
2023-03-08 09:16:04 +08:00
commit e78454540f
1318 changed files with 210569 additions and 0 deletions

45
app/Models/Google2FA.php Normal file
View File

@@ -0,0 +1,45 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\MorphTo;
class Google2FA extends Model
{
protected $casts = [
'status' => 'boolean',
];
public function subscriber(): MorphTo
{
return $this->morphTo();
}
/**
* Notes : 更新密钥
*
* @Date : 2022/11/30 20:51
* @Author : <Jason.C>
*/
public function upgrade()
{
$google2fa = app('pragmarx.google2fa');
$this->secret = $google2fa->generateSecretKey(32);
$this->save();
}
/**
* Notes : 验证
*
* @Date : 2022/11/30 20:49
* @Author : <Jason.C>
* @param string $value
* @return bool
*/
public function verify(string $value): bool
{
$google2fa = app('pragmarx.google2fa');
return $google2fa->verifyGoogle2FA($this->secret, $value);
}
}