Exemplo n.º 1
0
 public function anonymeAction($estAuthentifier = FALSE)
 {
     $configuration = $this->getDI()->get("config");
     if ($configuration->application->authentification->permettreAccesAnonyme) {
         if (!$this->session->has("info_utilisateur")) {
             $this->session->set("info_utilisateur", new SessionController());
         }
         if (estAuthentifier !== TRUE) {
             $this->session->get("info_utilisateur")->estAuthentifie = false;
             $this->session->get("info_utilisateur")->estAnonyme = true;
         }
         if ($configuration->offsetExists("database")) {
             if ($configuration->application->authentification->activerSelectionRole) {
                 $this->session->get("info_utilisateur")->profilActif = IgoProfil::findFirst("nom = '{$configuration->application->authentification->nomProfilAnonyme}'")->id;
             } else {
                 $this->session->get("info_utilisateur")->profils = IgoProfil::find("nom = '{$configuration->application->authentification->nomProfilAnonyme}'")->toArray();
             }
         }
         return $this->redirigeVersPage();
     } else {
         $this->dispatcher->forward(array("controller" => "error", "action" => "error403"));
     }
 }
Exemplo n.º 2
0
 function obtenirUtilisateurProfilsInQuery()
 {
     global $app;
     $authentificationModule = $app->getDI()->get("authentificationModule");
     if (estAnonyme($app->getDI()->getSession())) {
         $configuration = $app->getDI()->get("config");
         if (!isset($configuration->application->authentification->nomProfilAnonyme)) {
             return (string) '0';
         }
         return (string) '0,' . IgoProfil::findFirst("nom = '{$configuration->application->authentification->nomProfilAnonyme}'")->id;
     }
     if (!is_null($app->getDI()->getSession()->get("info_utilisateur")->profilActif)) {
         $profil = $app->getDI()->getSession()->get("info_utilisateur")->profilActif;
         return (string) '0,' . $profil;
     } else {
         $profils = obtenirProfils($app->getDI()->getSession());
         $profilsArray = array();
         foreach ($profils as $profil) {
             array_push($profilsArray, $profil["id"]);
         }
         array_push($profilsArray, 0);
         // défaut
         return implode(",", $profilsArray);
     }
 }
Exemplo n.º 3
0
 public function beforeExecuteRoute(Phalcon\Events\Event $event, Phalcon\Mvc\Dispatcher $dispatcher)
 {
     $authentificationModule = $this->getDI()->get("authentificationModule");
     if ($authentificationModule == null) {
         return;
     }
     $controller = $dispatcher->getControllerName();
     $action = $dispatcher->getActionName();
     $config = $this->getDI()->get("config");
     if ($controller === "connexion" || $controller === "error") {
         $config = $this->getDI()->get("config");
         $this->getDI()->get("view")->setViewsDir($config->application->services->viewsDir);
     } else {
         if ($controller === "igo" && ($action === "configuration" || $action === "index")) {
             $configuration = $this->obtenirConfiguration($action, $dispatcher);
             if (isset($this->getDi()->getConfig()->configurations[$configuration])) {
                 $file = $this->getDi()->getConfig()->configurations[$configuration];
             } else {
                 $file = $this->getDi()->getConfig()->configurationsDir . $configuration . '.xml';
             }
             if (!file_exists($file) && !curl_url_exists($file)) {
                 return $this->forwardToErrorPage();
             }
             if ($this->estAuthentificationRequise($configuration) && !$this->estAnonyme() && !$this->estAuthentifie()) {
                 return $this->forwardToLoginPage();
             } else {
                 if ($this->estAuthentificationRequise($configuration) && $this->estRoleSelectionneRequis() && !$this->estRoleSelectionne()) {
                     return $this->forwardToRolePage();
                 } else {
                     if (!$this->estAuthentificationRequise($configuration) && !$this->estAuthentifie()) {
                         $authentificationModule = $this->getDI()->get("authentificationModule");
                         if (!$this->session->has("info_utilisateur")) {
                             $this->session->set("info_utilisateur", new SessionController());
                         }
                         $configuration = $this->getDI()->get("config");
                         if ($configuration->offsetExists("database")) {
                             // Si la BD n'existe pas dans la config on n'ajoute pas de profil et on se base sur le xml
                             if ($this->estRoleSelectionneRequis()) {
                                 $this->session->get("info_utilisateur")->profilActif = IgoProfil::findFirst("nom = '{$configuration->application->authentification->nomProfilAnonyme}'")->id;
                             } else {
                                 if (isset($configuration->application->authentification->nomProfilAnonyme)) {
                                     $this->session->get("info_utilisateur")->profils = IgoProfil::find("nom = '{$configuration->application->authentification->nomProfilAnonyme}'");
                                 }
                             }
                         }
                         $this->session->get("info_utilisateur")->estAnonyme = true;
                     } else {
                         if ($this->estRoleSelectionneRequis() && !$this->estRoleSelectionne()) {
                             return $this->forwardToRolePage();
                         }
                     }
                 }
             }
             if ($this->estAnonyme() && isset($config->application->authentification->permettreAccesAnonyme) && !$config->application->authentification->permettreAccesAnonyme) {
                 return $this->forwardToUnauthorizedPage();
             }
         } else {
             if ($controller == "igo" && ($action == "contexte" || $action == "couche" || $action == "groupe")) {
                 if (!$this->estAnonyme() && !$this->estAuthentifie()) {
                     return $this->forwardToLoginPage();
                 } else {
                     if ($this->estRoleSelectionneRequis() && !$this->estRoleSelectionne()) {
                         return $this->forwardToRolePage();
                     }
                 }
                 if ($this->estAnonyme() && isset($config->application->authentification->permettreAccesAnonyme) && !$config->application->authentification->permettreAccesAnonyme) {
                     return $this->forwardToUnauthorizedPage();
                 }
             }
         }
     }
 }