mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 09:18:54 +00:00
c33db34c49
[ci skip] [skip ci]
42 lines
1.0 KiB
PHP
42 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Support;
|
|
|
|
use PragmaRX\Google2FALaravel\Exceptions\InvalidSecretKey;
|
|
use PragmaRX\Google2FALaravel\Support\Authenticator;
|
|
|
|
class Google2FAAuthenticator extends Authenticator
|
|
{
|
|
/**
|
|
* @return bool
|
|
*/
|
|
protected function canPassWithoutCheckingOTP(): bool
|
|
{
|
|
if (! $this->getUser()->passwordSecurity) {
|
|
return true;
|
|
}
|
|
|
|
return
|
|
! $this->getUser()->passwordSecurity->google2fa_enable ||
|
|
! $this->isEnabled() ||
|
|
$this->noUserIsAuthenticated() ||
|
|
$this->twoFactorAuthStillValid();
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*
|
|
* @throws \PragmaRX\Google2FALaravel\Exceptions\InvalidSecretKey
|
|
*/
|
|
protected function getGoogle2FASecretKey()
|
|
{
|
|
$secret = $this->getUser()->passwordSecurity->{$this->config('otp_secret_column')};
|
|
|
|
if (is_null($secret) || empty($secret)) {
|
|
throw new InvalidSecretKey('Secret key cannot be empty.');
|
|
}
|
|
|
|
return $secret;
|
|
}
|
|
}
|