Example #1
0
 /**
  * update the password of the current user.
  * if MODE_DEMO is TRUE, the password can't be updated.
  * @todo add the return value
  * @todo set the new password in function header like this updatePassword($newPassword)
  * @return boolean
  */
 public function updatePassword($password, $confirmPassword)
 {
     if (MODE_DEMO) {
         $this->messages->add('i', _('in demo mode, you can\'t update your password'));
         Tools::logm('in demo mode, you can\'t do this');
         Tools::redirect('?view=config');
     } else {
         if (isset($password) && isset($confirmPassword)) {
             if ($password == $confirmPassword && !empty($password)) {
                 $this->messages->add('s', _('your password has been updated'));
                 $this->store->updatePassword($this->user->getId(), Tools::encodeString($password . $this->user->getUsername()));
                 Session::logout();
                 Tools::logm('password updated');
                 Tools::redirect();
             } else {
                 $this->messages->add('e', _('the two fields have to be filled & the password must be the same in the two fields'));
                 Tools::redirect('?view=config');
             }
         }
     }
 }
Example #2
0
        <script src="lib/jquery-ui-1.11.4.custom/external/jquery/jquery.js"></script>
        <script src="lib/jquery-ui-1.11.4.custom/jquery-ui.js"></script>

        <?php 
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    require_once 'php/database.php';
    require_once 'php/index.php';
    $database = new Database();
    $database->connect();
    $index = new Index();
    $displayLoginFailedModal = FALSE;
    if (isset($_POST['email'])) {
        $email = $_POST['email'];
        if ($database->checkRegisteredEmail($email)) {
            $newPassword = $index->sendPasswordRecoveryEmail($email);
            $database->updatePassword($email, $newPassword);
        }
    } elseif (isset($_POST['username']) && isset($_POST['password'])) {
        $username = $_POST['username'];
        $password = $_POST['password'];
        if ($database->loginUser($username, $password)) {
            header('Location: classes/Newsfeed/newsfeed.php');
            //die();
        } else {
            $displayLoginFailedModal = TRUE;
        }
    }
}
?>

    </head>