mirror of
https://github.com/elyby/accounts.git
synced 2024-11-15 09:48:42 +05:30
951b6928a2
Поправлены именования классов (хз, почему оно прежде работало)
31 lines
649 B
PHP
31 lines
649 B
PHP
<?php
|
|
namespace api\models\base;
|
|
|
|
use Yii;
|
|
|
|
class PasswordProtectedForm extends ApiForm {
|
|
|
|
public $password;
|
|
|
|
public function rules() {
|
|
return [
|
|
[['password'], 'required', 'message' => 'error.{attribute}_required'],
|
|
[['password'], 'validatePassword'],
|
|
];
|
|
}
|
|
|
|
public function validatePassword() {
|
|
if (!$this->getAccount()->validatePassword($this->password)) {
|
|
$this->addError('password', 'error.password_invalid');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return \common\models\Account
|
|
*/
|
|
protected function getAccount() {
|
|
return Yii::$app->user->identity;
|
|
}
|
|
|
|
}
|