public function validate() { $errors = parent::validate(); if (!isset($errors['email'])) { $user = User::findOneBy(['email' => $this->data['email']]); if ($user) { $errors['email'] = new Error('Пользователь с таким email уже существует'); } } if (count($errors) == 0) { if ($this->data['password'] != $this->data['repeatPassword']) { $error = new Error('Пароли должны совпадать'); $errors['password'] = $error; $errors['repeatPassword'] = $error; } } return $errors; }
public function validate() { $errors = parent::validate(); if (empty($errors)) { $email = $this->getData()['email']; $password = $this->getData()['password']; $user = User::findOneBy(array('email' => $email)); if (!$user) { $errors['email'] = new Error('Неправильно введен логин или пароль'); } else { /** @var Security $security */ $security = Application::getInstance()->getComponent('security'); if ($user->password != $security->getPasswordHash($password, $user->salt)) { $errors['email'] = new Error('Неправильно введен логин или пароль'); } } } return $errors; }