public function executeIndex($request)
 {
     $this->form = new sfGuardRequestForgotPasswordForm();
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $this->user = $this->form->user;
             $this->_deleteOldUserForgotPasswordRecords();
             $forgotPassword = new sfGuardForgotPassword();
             $forgotPassword->user_id = $this->form->user->id;
             $forgotPassword->unique_key = md5(rand() + time());
             $forgotPassword->expires_at = new Doctrine_Expression('NOW()');
             $forgotPassword->save();
             $message = Swift_Message::newInstance()->setFrom(sfConfig::get('app_sf_guard_plugin_default_from_email', '*****@*****.**'))->setTo($this->form->user->email_address)->setSubject('Forgot Password Request for ' . $this->form->user->username)->setBody($this->getPartial('sfGuardForgotPassword/send_request', array('user' => $this->form->user, 'forgot_password' => $forgotPassword)))->setContentType('text/html');
             //        $message = Swift_Message::newInstance()
             //          ->setFrom('*****@*****.**')
             //          ->setTo('*****@*****.**')
             //          ->setSubject('test')
             //          ->setBody('test')
             //          ->setContentType('text/html')
             //        ;
             $this->getMailer()->send($message);
             $this->getUser()->setFlash('notice', 'Check your e-mail! You should receive something shortly!');
             $this->redirect('@sf_guard_signin');
         } else {
             $this->getUser()->setFlash('error', 'Invalid e-mail address!');
         }
     }
 }
 public function executeIndex($request)
 {
     $this->form = new sfGuardRequestForgotPasswordForm();
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $this->user = Doctrine_Core::getTable('sfGuardUser')->retrieveByUsernameOrEmailAddress($this->form->getValue('email_address'));
             Doctrine_Core::getTable('sfGuardForgotPassword')->deleteByUser($this->user);
             $forgotPassword = new sfGuardForgotPassword();
             $forgotPassword->user_id = $this->user->id;
             $forgotPassword->unique_key = md5(rand() + time());
             $forgotPassword->expires_at = new Doctrine_Expression('NOW()');
             $forgotPassword->save();
             $this->sendRequestMail($this->user, $forgotPassword);
             $this->getUser()->setFlash('notice', 'Check your e-mail! You should receive something shortly!');
             $this->redirect(sfConfig::get('app_sf_guard_plugin_password_request_url', '@sf_guard_signin'));
         }
     }
 }
 public function executeIndex($request)
 {
     $this->form = new sfGuardRequestForgotPasswordForm();
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $this->user = $this->form->user;
             $this->_deleteOldUserForgotPasswordRecords();
             $forgotPassword = new sfGuardForgotPassword();
             $forgotPassword->user_id = $this->form->user->id;
             $forgotPassword->unique_key = md5(rand() + time());
             $forgotPassword->expires_at = new Doctrine_Expression('NOW()');
             $forgotPassword->save();
             $message = Swift_Message::newInstance()->setFrom(array(sfConfig::get('app_correo_admin') => sfConfig::get('app_nombre_admin')))->setTo($this->form->user->email_address)->setSubject('¿Olvidó su contraseña? Solicitud de ' . $this->form->user->username)->setBody($this->getPartial('sfGuardForgotPassword/send_request', array('user' => $this->form->user, 'forgot_password' => $forgotPassword)))->setContentType('text/html');
             $this->getMailer()->send($message);
             $this->getUser()->setFlash('notice', 'Por favor, revise su correo electrónico y siga las indicaciones.');
             $this->redirect('@sf_guard_signin');
         } else {
             $this->getUser()->setFlash('error', '¡Dirección de correo electrónico invalida!');
         }
     }
 }
Esempio n. 4
0
 public function executeIndex($request)
 {
     $this->form = new sfGuardRequestForgotPasswordForm();
     $this->getUser()->setCulture('fr_FR');
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $this->user = $this->form->user;
             $this->_deleteOldUserForgotPasswordRecords();
             $forgotPassword = new sfGuardForgotPassword();
             $forgotPassword->user_id = $this->form->user->id;
             $forgotPassword->unique_key = md5(rand() + time());
             $forgotPassword->expires_at = new Doctrine_Expression('NOW()');
             $forgotPassword->save();
             $message = Swift_Message::newInstance()->setFrom(sfConfig::get('app_sf_guard_plugin_default_from_email', '*****@*****.**'))->setTo($this->form->user->email_address)->setSubject('Forgot Password Request for ' . $this->form->user->username)->setBody($this->getPartial('sfGuardForgotPassword/send_request', array('user' => $this->form->user, 'forgot_password' => $forgotPassword)))->setContentType('text/html');
             $this->getMailer()->send($message);
             $this->getUser()->setFlash('notice', 'Un e-mail vous a été envoyé!');
             $this->redirect('@identificationProfile');
         } else {
             $this->getUser()->setFlash('error', 'Adresse e-mail invalide!');
         }
     }
 }
Esempio n. 5
0
 public function executeIndex($request)
 {
     $this->form = new sfGuardRequestForgotPasswordForm();
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $this->user = $this->form->user;
             Doctrine_Core::getTable('sfGuardForgotPassword')->createQuery('p')->delete()->where('p.user_id = ?', $this->user->id)->execute();
             $forgotPassword = new sfGuardForgotPassword();
             $forgotPassword->user_id = $this->form->user->id;
             $forgotPassword->unique_key = md5(rand() + time());
             $forgotPassword->expires_at = new Doctrine_Expression('NOW()');
             $forgotPassword->save();
             $message = $this->getMailer()->compose(array(sfConfig::get('app_info_email') => sfConfig::get('app_sf_guard_plugin_default_from_email')), $this->form->user->email_address, 'Forgot Password Request for ' . $this->form->user->username);
             $message->setBody($this->getPartial('sfGuardForgotPassword/send_request', array('user' => $this->form->user, 'forgot_password' => $forgotPassword)));
             $message->setContentType('text/html');
             $this->getMailer()->send($message);
             $this->getUser()->setFlash('notice', 'Check your e-mail! You should receive something shortly!');
             $this->redirect('@sf_guard_signin');
         } else {
             $this->getUser()->setFlash('error', 'Invalid e-mail address!');
         }
     }
 }
Esempio n. 6
0
 public function executeForgotten($request)
 {
     /* @var $request sfWebRequest */
     if (!$request->isXmlHttpRequest()) {
         $this->redirect404();
     }
     $user = $this->getUser();
     if ($user->isAuthenticated()) {
         return $this->redirect('@homepage');
     }
     $form = new sfGuardRequestForgotPasswordForm();
     if ($request->isMethod('post')) {
         $form->bind($request->getParameter($form->getName()));
         if ($form->isValid()) {
             //        $this->user = $form->user;
             $this->_deleteOldUserForgotPasswordRecords($form->user->id);
             $salt = '';
             while (strlen($salt) < 16) {
                 $salt .= base_convert(mt_rand(), 10, 36);
             }
             $salt = substr($salt, 0, 16);
             $code = base_convert(sha1('policat' . mt_rand() . microtime() . mt_rand() . mt_rand()), 16, 36);
             $forgotPassword = new sfGuardForgotPassword();
             $forgotPassword->user_id = $form->user->id;
             $forgotPassword->unique_key = crypt($code, '$6$' . $salt);
             $forgotPassword->expires_at = new Doctrine_Expression('NOW()');
             $forgotPassword->save();
             //        $message = Swift_Message::newInstance()
             //          ->setFrom(sfConfig::get('app_sf_guard_plugin_default_from_email', '*****@*****.**'))
             //          ->setTo($this->form->user->email_address)
             //          ->setSubject('Forgot Password Request for ' . $this->form->user->username)
             //          ->setBody($this->getPartial('sfGuardForgotPassword/send_request', array('user' => $this->form->user, 'forgot_password' => $forgotPassword)))
             //          ->setContentType('text/html')
             //        ;
             //
             //        $this->getMailer()->send($message);
             $subject = 'password forgotten';
             $body = "#VALIDATION-URL#";
             $store = StoreTable::getInstance()->findByKeyAndLanguageWithFallback(StoreTable::PASSWORD_FORGOTTEN_MAIL, $form->user->getLanguageId());
             if ($store) {
                 $subject = $store->getField('subject');
                 $body = $store->getField('body');
             }
             $subst = array('#VALIDATION-URL#' => $this->generateUrl('password_reset', array('id' => $form->user->getId(), 'code' => $code), true), '#USER-NAME#' => $form->user->getFullName());
             UtilMail::send(null, null, $form->user->getEmailAddress(), $subject, $body, null, $subst);
             return $this->ajax()->remove('#forgotten_modal .alert')->attr('#forgotten_modal input, #forgotten_modal button', 'disabled', 'disabled')->alert('Request accepted. Check your mail now.', '', '#forgotten_modal .modal-body', 'append')->render();
         } else {
             return $this->ajax()->remove('#forgotten_modal .alert')->alert('Wrong email address.', 'Error', '#forgotten_modal .modal-body', 'append')->render();
         }
     } else {
         return $this->ajax()->remove('#forgotten_modal')->appendPartial('body', 'forgotten', array('form' => $form))->modal('#login_modal', 'hide')->modal('#forgotten_modal')->render();
     }
 }