Example #1
0
 private function checkAuth(Application $app, Database $db, \DBMappers\EmpItem $empMapper)
 {
     //error_log("\nauthorized" . print_r($app->isAuthorized(), true), 3, 'my_errors.txt');
     //error_log("\nsession" . print_r($registry->get(REG_SESSION), true), 3, 'my_errors.txt');
     if (!$app->isAuthorized() && $this->controllerName != LOGIN_CONTROLLER) {
         $this->controllerName = DEFAULT_CONTROLLER;
         $this->actionName = DEFAULT_ACTION;
     } else {
         if ($this->controllerName != LOGIN_CONTROLLER) {
             $empItem = $empMapper->getById($app->getEmpId(), $db);
             if (is_object($empItem)) {
                 $app->setAuthorized($empItem->getId(), $empItem->isAdmin(), $empItem->getFirstDay(), $empItem->getHourMode());
             } else {
                 $app->reopenSession();
                 $this->controllerName = DEFAULT_CONTROLLER;
                 $this->actionName = DEFAULT_ACTION;
             }
         }
     }
 }