protected function doClean($value)
 {
     $clean = (string) $value;
     // user exists?
     if (!is_null(sfGuardUserPeer::retrieveByUsernameOrEmail($clean))) {
         return $value;
     }
     throw new sfValidatorError($this, 'invalid', array('value' => $value));
 }
 /**
  * executePassword
  *
  * Form for requesting instructions on how to reset your password
  *
  * @param  sfRequest $request
  * @return void
  * @author Jonathan H. Wage
  */
 public function executePassword(sfWebRequest $request)
 {
     $this->form = new sfGuardFormForgotPassword();
     if ($request->isMethod(sfRequest::POST)) {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $values = $this->form->getValues();
             $sfGuardUser = sfGuardUserPeer::retrieveByUsernameOrEmail($values['username_or_email'], true);
             $this->forward404Unless($sfGuardUser, 'user not found');
             $messageParams = array('sfGuardUser' => $sfGuardUser);
             $body = $this->getComponent($this->getModuleName(), 'send_request_reset_password', $messageParams);
             $from = sfConfig::get('app_sf_guard_extra_plugin_mail_from', '*****@*****.**');
             $fromName = sfConfig::get('app_sf_guard_extra_plugin_name_from', 'noreply');
             $to = $sfGuardUser->getEmail();
             $toName = $sfGuardUser->getUsername();
             $subject = sfConfig::get('app_sf_guard_extra_plugin_subject_request', 'Request to reset password');
             $mailer = $this->getMailer();
             $message = $mailer->compose(array($from => $fromName), array($to => $toName), $subject, $body);
             $mailer->send($message);
             return $this->redirect('@sf_guard_do_password?' . http_build_query($values));
         }
     }
 }