public function control()
 {
     $controller = new LoginController(true);
     if ($this->is_missing_param) {
         $controller->addErrorMessage('Invalid account activation credentials.');
     } else {
         $owner_dao = DAOFactory::getDAO('OwnerDAO');
         $acode = $owner_dao->getActivationCode($_GET['usr']);
         if ($_GET['code'] == $acode['activation_code']) {
             $owner = $owner_dao->getByEmail($_GET['usr']);
             if (isset($owner) && isset($owner->is_activated)) {
                 if ($owner->is_activated == 1) {
                     $controller->addSuccessMessage("You have already activated your account. Please log in.");
                 } else {
                     $owner_dao->activateOwner($_GET['usr']);
                     $controller->addSuccessMessage("Success! Your account has been activated. Please log in.");
                 }
             } else {
                 $controller->addErrorMessage('Houston, we have a problem: Account activation failed.');
             }
         } else {
             $controller->addErrorMessage('Houston, we have a problem: Account activation failed.');
         }
     }
     return $controller->go();
 }
 public function control()
 {
     $session = new Session();
     $dao = DAOFactory::getDAO('OwnerDAO');
     $this->setViewTemplate('session.resetpassword.tpl');
     $this->disableCaching();
     if (!isset($_GET['token']) || !preg_match('/^[\\da-f]{32}$/', $_GET['token']) || !($user = $dao->getByPasswordToken($_GET['token']))) {
         // token is nonexistant or bad
         $this->addErrorMessage('You have reached this page in error.');
         return $this->generateView();
     }
     if (!$user->validateRecoveryToken($_GET['token'])) {
         $this->addErrorMessage('Your token is expired.');
         return $this->generateView();
     }
     if (isset($_POST['password'])) {
         if ($_POST['password'] == $_POST['password_confirm']) {
             if ($dao->updatePassword($user->email, $session->pwdcrypt($_POST['password'])) < 1) {
                 echo "not updated";
             }
             $login_controller = new LoginController(true);
             $login_controller->addSuccessMessage('You have changed your password.');
             return $login_controller->go();
         } else {
             $this->addErrorMessage("Passwords didn't match.");
         }
     } else {
         if (isset($_POST['Submit'])) {
             $this->addErrorMessage('Please enter a new password.');
         }
     }
     return $this->generateView();
 }
 public function control()
 {
     $session = new Session();
     $owner_dao = DAOFactory::getDAO('OwnerDAO');
     $this->view_mgr->addHelp('reset', 'userguide/accounts/index');
     $this->setViewTemplate('session.resetpassword.tpl');
     $this->addHeaderJavaScript('assets/js/jqBootstrapValidation.js');
     $this->addHeaderJavaScript('assets/js/validate-fields.js');
     $this->disableCaching();
     $config = Config::getInstance();
     $this->addToView('is_registration_open', $config->getValue('is_registration_open'));
     if (!isset($_GET['token']) || !preg_match('/^[\\da-f]{32}$/', $_GET['token']) || !($user = $owner_dao->getByPasswordToken($_GET['token']))) {
         // token is nonexistant or bad
         $this->addErrorMessage('You have reached this page in error.');
         return $this->generateView();
     }
     if (!$user->validateRecoveryToken($_GET['token'])) {
         $this->addErrorMessage('Your token is expired.');
         return $this->generateView();
     }
     if (isset($_POST['password'])) {
         if ($_POST['password'] == $_POST['password_confirm']) {
             $login_controller = new LoginController(true);
             // Try to update the password
             if ($owner_dao->updatePassword($user->email, $_POST['password']) < 1) {
                 $login_controller->addErrorMessage('Problem changing your password!');
             } else {
                 $owner_dao->activateOwner($user->email);
                 $owner_dao->clearAccountStatus($user->email);
                 $owner_dao->resetFailedLogins($user->email);
                 $owner_dao->updatePasswordToken($user->email, '');
                 $login_controller->addSuccessMessage('You have changed your password.');
             }
             return $login_controller->go();
         } else {
             $this->addErrorMessage("Passwords didn't match.");
         }
     } else {
         if (isset($_POST['Submit'])) {
             $this->addErrorMessage('Please enter a new password.');
         }
     }
     return $this->generateView();
 }
Exemplo n.º 4
0
 public function authControl()
 {
     $user_logon = DAOFactory::getDAO('UserLogonDAO');
     if (isset($_GET['reason'])) {
         $reason = 2;
     } else {
         $reason = 1;
     }
     $user_logon->userLogoutUpdate($reason);
     Session::logout();
     if (!$this->redirectToSternIndiaEndpoint('logout.php')) {
         $controller = new LoginController(true);
         if ($reason) {
             $controller->reason = $reason;
         }
         $controller->addSuccessMessage("You have successfully logged out.");
         return $controller->go();
     }
 }