/**
  * Sends an email with a link, for resetting the password.
  *
  * @return boolean whether the email was send
  */
 public function sendEmail()
 {
     $user = Account::findOne(['status' => Account::STATUS_ACTIVE, 'email' => $this->email]);
     if ($user) {
         if (!Account::isTokenValid($user->password_reset_token)) {
             $user->generatePasswordResetToken();
         }
         if ($user->save()) {
             $email = Yii::$app->mailer->compose(['html' => 'password-reset-token-html', 'text' => 'password-reset-token-text'], ['user' => $user])->setFrom([Setting::getValue('outgoingMail') => \Yii::$app->name])->setTo($this->email)->setSubject(Yii::t('app', 'Password reset for {APP_NAME}', ['APP_NAME' => \Yii::$app->name]));
             return $email->send();
         }
     }
     return false;
 }
 /**
  * Finds the Account model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Account the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Account::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.'));
     }
 }