mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Added 2fa code validation
This commit is contained in:
@@ -16,10 +16,13 @@ use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Rules\Triggers\TriggerInterface;
|
||||
use FireflyIII\User;
|
||||
use Input;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Illuminate\Validation\Validator;
|
||||
use Log;
|
||||
use PragmaRX\Google2FA\Contracts\Google2FA;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Session;
|
||||
|
||||
/**
|
||||
* Class FireflyValidator
|
||||
@@ -43,6 +46,29 @@ class FireflyValidator extends Validator
|
||||
parent::__construct($translator, $data, $rules, $messages, $customAttributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $attribute
|
||||
* @param $value
|
||||
* @param $parameters
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function validate2faCode($attribute, $value, $parameters): bool
|
||||
{
|
||||
if (!is_string($value) || is_null($value) || strlen($value) <> 6) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Retrieve the secret from our hidden form field.
|
||||
$secret = Input::get($parameters[0]);
|
||||
|
||||
$google2fa = app('PragmaRX\Google2FA\Google2FA');
|
||||
|
||||
return $google2fa->verifyKey($secret, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $attribute
|
||||
* @param $value
|
||||
|
Reference in New Issue
Block a user