mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Переработана структура тестов для формы аутентификации
This commit is contained in:
@ -17,23 +17,17 @@ class AuthenticationForm extends Model {
|
||||
return [
|
||||
['email', 'required', 'message' => 'error.email_required'],
|
||||
['email', 'email', 'message' => 'error.email_invalid'],
|
||||
['email', 'validateEmail'],
|
||||
['email', 'exist', 'targetClass' => Account::class, 'skipOnError' => true, 'message' => 'error.email_not_exist'],
|
||||
|
||||
['password', 'required', 'message' => 'error.password_required'],
|
||||
['password', 'required', 'when' => function(self $model) {
|
||||
return !$model->hasErrors();
|
||||
}, 'message' => 'error.password_required'],
|
||||
['password', 'validatePassword'],
|
||||
|
||||
['rememberMe', 'boolean'],
|
||||
];
|
||||
}
|
||||
|
||||
public function validateEmail($attribute) {
|
||||
if (!$this->hasErrors()) {
|
||||
if ($this->getAccount() === NULL) {
|
||||
$this->addError($attribute, 'error.email_not_exist');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function validatePassword($attribute) {
|
||||
if (!$this->hasErrors()) {
|
||||
$account = $this->getAccount();
|
||||
|
Reference in New Issue
Block a user