Exemplo n.º 1
0
 public function lostpasswordAction()
 {
     $username = $this->_getParam("username");
     if ($username) {
         $user = User::getByName($username);
         if (!$user instanceof User) {
             $this->view->error = "user unknown";
         } else {
             if ($user->isActive()) {
                 if ($user->getEmail()) {
                     $token = Pimcore_Tool_Authentication::generateToken($username, $user->getPassword(), MCRYPT_TRIPLEDES, MCRYPT_MODE_ECB);
                     $protocol = "http://";
                     if (strpos(strtolower($_SERVER["SERVER_PROTOCOL"]), "https") === 0) {
                         $protocol = "https://";
                     }
                     $uri = $protocol . $_SERVER['SERVER_NAME'];
                     $loginUrl = $uri . "/admin/login/login/?username="******"&token=" . $token;
                     try {
                         $mail = Pimcore_Tool::getMail(array($user->getEmail()), "Pimcore lost password service");
                         $mail->setBodyText("Login to pimcore and change your password using the following link. This temporary login link will expire in 30 minutes: \r\n\r\n" . $loginUrl);
                         $mail->send();
                         $this->view->success = true;
                     } catch (Exception $e) {
                         $this->view->error = "could not send email";
                     }
                 } else {
                     $this->view->error = "user has no email address";
                 }
             } else {
                 $this->view->error = "user inactive";
             }
         }
     }
 }
Exemplo n.º 2
0
 public function lostpasswordAction()
 {
     $username = $this->_getParam("username");
     if ($username) {
         $user = User::getByName($username);
         if (!$user instanceof User) {
             $this->view->error = "user unknown";
         } else {
             if ($user->isActive()) {
                 if ($user->getEmail()) {
                     $token = Pimcore_Tool_Authentication::generateToken($username, $user->getPassword(), MCRYPT_TRIPLEDES, MCRYPT_MODE_ECB);
                     $uri = $this->getRequest()->getScheme() . "://" . $this->getRequest()->getHttpHost();
                     $loginUrl = $uri . "/admin/login/login/?username="******"&token=" . $token . "&reset=true";
                     try {
                         $mail = Pimcore_Tool::getMail(array($user->getEmail()), "Pimcore lost password service");
                         $mail->setIgnoreDebugMode(true);
                         $mail->setBodyText("Login to pimcore and change your password using the following link. This temporary login link will expire in 30 minutes: \r\n\r\n" . $loginUrl);
                         $mail->send();
                         $this->view->success = true;
                     } catch (Exception $e) {
                         $this->view->error = "could not send email";
                     }
                 } else {
                     $this->view->error = "user has no email address";
                 }
             } else {
                 $this->view->error = "user inactive";
             }
         }
     }
 }