Exemple #1
0
 public function password()
 {
     $this->setTitle('Change your password - Savely.co');
     $f = new Form('password');
     if ($f->isValid()) {
         $v = $f->getValues();
         if (ModelAuthentication::getInstance()->changePassword($v['currentPassword'], $v['newPassword'])) {
             AuthenticationHandler::unsetUserSession();
             AuthenticationHandler::setUserSession(ModelAuthentication::getInstance()->getLogin(), $v['newPassword']);
             $this->addContent('confirmation', 'New Password Saved');
         } else {
             $this->addContent('error', 'You current password does not match');
         }
     } else {
         $this->addContent('error', $f->getError());
     }
     $this->addForm('password', $f);
 }
 /**
  * Méthode de définition des variables de session pour l'instance d'authentication en cours
  * @param  $pLogin
  * @param  $pMdp
  * @param bool $pAdmin
  * @return bool
  */
 public function setAuthentication($pLogin, $pMdp, $pAdmin = false)
 {
     if (ModelAuthentication::isUser($pLogin, $pMdp)) {
         $lvl = AuthenticationHandler::$permissions[AuthenticationHandler::USER];
         if ($pAdmin) {
             $lvl = AuthenticationHandler::$permissions[AuthenticationHandler::ADMIN];
         }
         $isAutorized = $lvl & ModelAuthentication::$data[Configuration::$authentication_fieldPermissions];
         if ($isAutorized) {
             $pMdp = ModelAuthentication::getInstance()->getPasswordHash();
             $token = $this->getToken($pMdp);
             $_SESSION[$this->sessionVar] = array("login_user" => $pLogin, "mdp_user" => $pMdp, "token" => $token);
             return true;
         }
     }
     return false;
 }