В форму включения двухфакторной аутентификации добавлено поле для фиксации времени запроса

This commit is contained in:
ErickSkrauch
2017-02-22 01:49:24 +03:00
parent 0eedfe91a2
commit 7bf8260331
3 changed files with 47 additions and 4 deletions

View File

@@ -23,6 +23,8 @@ class TwoFactorAuthForm extends ApiForm {
public $token;
public $timestamp;
public $password;
/**
@@ -38,10 +40,16 @@ class TwoFactorAuthForm extends ApiForm {
public function rules() {
$bothScenarios = [self::SCENARIO_ACTIVATE, self::SCENARIO_DISABLE];
return [
['timestamp', 'integer', 'on' => [self::SCENARIO_ACTIVATE]],
['account', 'validateOtpDisabled', 'on' => self::SCENARIO_ACTIVATE],
['account', 'validateOtpEnabled', 'on' => self::SCENARIO_DISABLE],
['token', 'required', 'message' => E::OTP_TOKEN_REQUIRED, 'on' => $bothScenarios],
['token', TotpValidator::class, 'account' => $this->account, 'window' => 30, 'on' => $bothScenarios],
['token', TotpValidator::class, 'on' => $bothScenarios,
'account' => $this->account,
'timestamp' => function() {
return $this->timestamp;
},
],
['password', PasswordRequiredValidator::class, 'account' => $this->account, 'on' => $bothScenarios],
];
}