mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Поле token в контексте otp токенов переименовано в totp
This commit is contained in:
@ -20,17 +20,17 @@ class ForgotPasswordForm extends ApiForm {
|
||||
|
||||
public $login;
|
||||
|
||||
public $token;
|
||||
public $totp;
|
||||
|
||||
public function rules() {
|
||||
return [
|
||||
['captcha', ReCaptchaValidator::class],
|
||||
['login', 'required', 'message' => E::LOGIN_REQUIRED],
|
||||
['login', 'validateLogin'],
|
||||
['token', 'required', 'when' => function(self $model) {
|
||||
['totp', 'required', 'when' => function(self $model) {
|
||||
return !$this->hasErrors() && $model->getAccount()->is_otp_enabled;
|
||||
}, 'message' => E::OTP_TOKEN_REQUIRED],
|
||||
['token', 'validateTotpToken'],
|
||||
}, 'message' => E::TOTP_REQUIRED],
|
||||
['totp', 'validateTotp'],
|
||||
['login', 'validateActivity'],
|
||||
['login', 'validateFrequency'],
|
||||
];
|
||||
@ -44,7 +44,7 @@ class ForgotPasswordForm extends ApiForm {
|
||||
}
|
||||
}
|
||||
|
||||
public function validateTotpToken($attribute) {
|
||||
public function validateTotp($attribute) {
|
||||
if ($this->hasErrors()) {
|
||||
return;
|
||||
}
|
||||
|
@ -17,10 +17,10 @@ class LoginForm extends ApiForm {
|
||||
|
||||
public $login;
|
||||
public $password;
|
||||
public $token;
|
||||
public $totp;
|
||||
public $rememberMe = false;
|
||||
|
||||
public function rules() {
|
||||
public function rules(): array {
|
||||
return [
|
||||
['login', 'required', 'message' => E::LOGIN_REQUIRED],
|
||||
['login', 'validateLogin'],
|
||||
@ -30,10 +30,10 @@ class LoginForm extends ApiForm {
|
||||
}, 'message' => E::PASSWORD_REQUIRED],
|
||||
['password', 'validatePassword'],
|
||||
|
||||
['token', 'required', 'when' => function(self $model) {
|
||||
['totp', 'required', 'when' => function(self $model) {
|
||||
return !$model->hasErrors() && $model->getAccount()->is_otp_enabled;
|
||||
}, 'message' => E::OTP_TOKEN_REQUIRED],
|
||||
['token', 'validateTotpToken'],
|
||||
}, 'message' => E::TOTP_REQUIRED],
|
||||
['totp', 'validateTotp'],
|
||||
|
||||
['login', 'validateActivity'],
|
||||
|
||||
@ -58,7 +58,7 @@ class LoginForm extends ApiForm {
|
||||
}
|
||||
}
|
||||
|
||||
public function validateTotpToken($attribute) {
|
||||
public function validateTotp($attribute) {
|
||||
if ($this->hasErrors()) {
|
||||
return;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ class TwoFactorAuthForm extends ApiForm {
|
||||
const SCENARIO_ACTIVATE = 'enable';
|
||||
const SCENARIO_DISABLE = 'disable';
|
||||
|
||||
public $token;
|
||||
public $totp;
|
||||
|
||||
public $timestamp;
|
||||
|
||||
@ -44,8 +44,8 @@ class TwoFactorAuthForm extends ApiForm {
|
||||
['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, 'on' => $bothScenarios,
|
||||
['totp', 'required', 'message' => E::TOTP_REQUIRED, 'on' => $bothScenarios],
|
||||
['totp', TotpValidator::class, 'on' => $bothScenarios,
|
||||
'account' => $this->account,
|
||||
'timestamp' => function() {
|
||||
return $this->timestamp;
|
||||
|
Reference in New Issue
Block a user