'trim'], ['email', 'required'], ['email', 'email'], ['email', 'exist', 'targetClass' => 'domain\User\User\User', 'message' => 'There is no user with such email.' ], ]; } /** * Sends an email with a link, for resetting the password. * * @return boolean whether the email was send */ public function sendEmail() { $userModule = UserModule::getInstance(); $user = $userModule->getRepository()->findOneUserByEmail($this->email); if ($user) { if (!$userModule->isPasswordResetTokenValid($user->password_reset_token)) { $userModule->generatePasswordResetToken($user); } if ($user->save()) { return \Yii::$app->mailerService->sendFromSite( 'Mot de passe oublié', 'passwordResetToken', ['user' => $user], $this->email ); } } return false; } }