mirror of
https://github.com/elyby/accounts.git
synced 2024-12-30 00:50:20 +05:30
8906370bb9
Подкорректирован errorDict на фронте
32 lines
667 B
PHP
32 lines
667 B
PHP
<?php
|
|
namespace api\models\base;
|
|
|
|
use common\helpers\Error as E;
|
|
use Yii;
|
|
|
|
class PasswordProtectedForm extends ApiForm {
|
|
|
|
public $password;
|
|
|
|
public function rules() {
|
|
return [
|
|
[['password'], 'required', 'message' => E::PASSWORD_REQUIRED],
|
|
[['password'], 'validatePassword'],
|
|
];
|
|
}
|
|
|
|
public function validatePassword() {
|
|
if (!$this->getAccount()->validatePassword($this->password)) {
|
|
$this->addError('password', E::PASSWORD_INVALID);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return \common\models\Account
|
|
*/
|
|
protected function getAccount() {
|
|
return Yii::$app->user->identity;
|
|
}
|
|
|
|
}
|