Exemple #1
0
            throw new Exception("une erreur est survenue -> 0x1");
        }
        $user->setRole($role);
        $user->setCompany($_POST['company']);
        //if already password save
        if (isset($_POST['password']) && strlen($_POST['password']) > 0) {
            if ($_POST['password'] != $_POST['passwordchk']) {
                throw new Exception("Le champs mot de passe et confirmation mot de passe doivent étre identiques");
            }
            $user->setPassword(SecurityManager::get()->hashPassword($_POST['password'], $user->getSalt()));
        } else {
            if ($user->getPassword() == null && strlen($_POST['password']) < 1) {
                throw new Exception("un mot de passe est requis");
            }
        }
        $userDao->save($user);
        header('Location:' . WEB_PATH . '?page=admin&tab=users');
    } catch (Exception $ex) {
        echo $error;
        $error = $ex->getMessage();
    }
}
//view Mode
if (isset($_GET['id'])) {
    $user = $userDao->getByPrimaryKey($_GET['id']);
    if ($user == null) {
        header('Location:' . WEB_PATH);
    }
} else {
    $user = new User();
}
 /**
  * logout user by session id
  * @param $session
  */
 public function logOutUser($session)
 {
     try {
         $userDao = new UserDao(self::$em);
         $user = $this->getCurrentUser($session);
         if ($user != null) {
             $user->setSession('');
             $userDao->save($user);
             return true;
         }
         return false;
     } catch (Exception $ex) {
         var_dump($ex);
     }
 }