account === null) { $this->account = Yii::$app->user->identity; } if (!$this->account instanceof Account) { throw new InvalidConfigException('account should be instance of ' . Account::class); } if (empty($this->account->otp_secret)) { throw new InvalidConfigException('account should have not empty otp_secret'); } } protected function validateValue($value) { $totp = new TOTP(null, $this->account->otp_secret); if (!$totp->verify((string)$value, null, $this->window)) { return [E::OTP_TOKEN_INCORRECT, []]; } return null; } }