コード例 #1
0
 public function login(Trace $trace, ServerConfig $serverConfig, LoginFactory $factory, AIS2ServerConnection $connection)
 {
     $login = $this->provideLogin($serverConfig, $factory, $this->request);
     if ($login === null) {
         return false;
     }
     $trace->tlog("logging in");
     if (!$login->login($connection)) {
         return false;
     }
     $trace->tlog("logged in correctly.");
     $this->session->write('login/login.class', $login);
     $this->session->write('server', $serverConfig);
     FajrUtils::redirect();
     // it should be safe to end script execution here.
     exit;
 }
コード例 #2
0
ファイル: Fajr.php プロジェクト: BGCX067/fajr-svn-to-git
 public function runLogic(Trace $trace, HttpConnection $connection)
 {
     $session = $this->context->getSessionStorage();
     $loginManager = new LoginManager($session, $this->context->getRequest());
     $server = $this->getServer();
     $serverConnection = new AIS2ServerConnection($connection, new AIS2ServerUrlMap($server->getServerName()));
     $action = $this->context->getRequest()->getParameter('action', 'studium.MojeTerminyHodnotenia');
     $response = $this->context->getResponse();
     if ($action == 'logout') {
         $loginManager->logout($serverConnection);
         FajrUtils::redirect(array(), 'index.php');
         exit;
     } else {
         if ($action == 'termsOfUse') {
             // TODO(anty): refactor this
             $response->setTemplate('termsOfUse');
             return;
         }
     }
     if ($loginManager->shouldLogin()) {
         $factory = $this->injector->getInstance('LoginFactory.class');
         $loginManager->login($trace->addChild("Logging in..."), $server, $factory, $serverConnection);
         $loggedIn = false;
         // login makes redirect on success
     } else {
         $loggedIn = $loginManager->isLoggedIn($serverConnection);
     }
     if ($loggedIn) {
         $controllerInjector = new Injector(array(new ControllerInjectorModule($serverConnection, $server, $session)));
         $mainScreen = $controllerInjector->getInstance('AIS2MainScreen.class');
         if (($aisVersion = $session->read('ais/aisVersion')) == null) {
             $aisVersion = $mainScreen->getAisVersion($trace->addChild('Get AIS version'));
             $session->write('ais/aisVersion', $aisVersion);
         }
         if (($aisApps = $session->read('ais/aisApps')) == null) {
             $aisApps = $mainScreen->getAllAvailableApplications($trace->addChild('Get all applications'));
             $session->write('ais/aisApps', $aisApps);
         }
         if (($userName = $session->read('ais/aisUserName')) == null) {
             $userName = $mainScreen->getFullUserName($trace->addChild('Get user name'));
             $session->write('ais/aisUserName', $userName);
         }
         $response->set('aisVersion', $aisVersion);
         $response->set('aisVersionIncompatible', !($aisVersion >= regression\VersionRange::getMinVersion() && $aisVersion <= regression\VersionRange::getMaxVersion()));
         $response->set('aisUserName', $userName);
         $controller = new DispatchController($controllerInjector, $this->injector->getParameter('controller.dispatchMap'));
         $response->set("action", $action);
         $controller->invokeAction($trace, $action, $this->context);
         $response->set('statistics', $this->statistics);
     } else {
         $server = $this->getServer();
         switch ($server->getLoginType()) {
             case 'password':
                 $response->setTemplate('welcome');
                 break;
             case 'cosign':
                 $response->setTemplate('welcomeCosign');
                 break;
             case 'cosignproxy':
                 $response->setTemplate('welcomeCosignProxy');
                 break;
             case 'nologin':
                 $response->setTemplate('welcomeDemo');
                 break;
             default:
                 throw new Exception("Invalid type of login");
         }
     }
 }
コード例 #3
0
 /**
  * Akcia ktora sa pokusi prihlasit cloveka na danu skusku
  *
  * @param Trace $trace trace object
  * @param Context $context
  */
 public function runPrihlasNaSkusku(Trace $trace, Context $context)
 {
     $request = $context->getRequest();
     $response = $context->getResponse();
     $predmetIndex = $request->getParameter("prihlasPredmetIndex");
     $terminIndex = $request->getParameter("prihlasTerminIndex");
     $predmety = $this->terminyHodnoteniaScreen->getPredmetyZapisnehoListu($trace->addChild('Predmety zapisneho listu'));
     FajrUtils::warnWrongTableStructure($response, 'terminy hodnotenia - predmety', regression\ZapisanePredmetyRegression::get(), $predmety->getTableDefinition());
     $predmetyData = $predmety->getData();
     $predmetKey = -1;
     foreach ($predmetyData as $key => $row) {
         if ((string) $row[PredmetyFields::INDEX] === $predmetIndex) {
             $predmetKey = $key;
         }
     }
     $childTrace = $trace->addChild('Zoznam terminov');
     $terminyDialog = $this->terminyHodnoteniaScreen->getZoznamTerminovDialog($childTrace, $predmetIndex);
     $terminy = $terminyDialog->getZoznamTerminov($childTrace);
     FajrUtils::warnWrongTableStructure($response, 'zoznam mojich terminov', regression\MojeTerminyRegression::get(), $terminy->getTableDefinition());
     $terminyData = $terminy->getData();
     $terminKey = -1;
     foreach ($terminyData as $key => $terminyRow) {
         if ((string) $terminyRow[TerminyFields::INDEX] === $terminIndex) {
             $terminKey = $key;
         }
     }
     if ($predmetKey == -1 || $terminKey == -1) {
         throw new Exception("Ooops, predmet/termín nenájdený. Pravdepodobne\n          zmena dát v AISe.");
     }
     $hash = StudiumUtils::hashNaPrihlasenie($predmetyData[$predmetKey][PredmetyFields::SKRATKA], $terminyData[$terminIndex]);
     if ($hash != $request->getParameter('hash')) {
         throw new Exception("Ooops, nesedia údaje o termíne. Pravdepodobne zmena\n          dát v AISe spôsobila posunutie tabuliek.");
     }
     if (!$terminyDialog->prihlasNaTermin($trace->addChild('prihlasujem na termin'), $terminIndex)) {
         throw new Exception('Na skúšku sa nepodarilo prihlásiť.');
     }
     $response->setTemplate('redirect');
     FajrUtils::redirect(array('action' => 'studium.MojeTerminyHodnotenia', 'studium' => $this->studium, 'list' => $this->zapisnyList));
 }