Last active
January 25, 2021 12:42
-
-
Save afiqiqmal/99cd3195f1fb79846d4f788505c1ecad to your computer and use it in GitHub Desktop.
TwoFactorAuthenticationProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class TwoFactorAuthenticationProvider | |
{ | |
protected $engine; | |
public function __construct(Google2FA $engine) | |
{ | |
$this->engine = $engine; | |
} | |
public function generateSecretKey() | |
{ | |
return $this->engine->generateSecretKey(); | |
} | |
public function generateRecoveryCodes($times = 8, $random = 10) | |
{ | |
return Collection::times($times, function () { | |
return Str::random($random).'-'.Str::random($random); | |
})->toArray(); | |
} | |
public function qrCodeUrl(string $companyName, string $companyEmail, string $secret) | |
{ | |
return $this->engine->getQRCodeUrl($companyName, $companyEmail, $secret); | |
} | |
public function verify(string $secret, string $code) | |
{ | |
return $this->engine->verifyKey($secret, $code); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment