diff options
| author | michael pereira | 2011-07-11 00:51:43 +0200 |
|---|---|---|
| committer | michael pereira | 2011-07-11 00:51:43 +0200 |
| commit | e01348134e7d44de9471c4d76659cab41a6c9952 (patch) | |
| tree | bba0e9343e6b7ed80fd57b7623fef01ae481357f /application/modules/ipxe/controllers/AuthController.php | |
| parent | Session fuer ipxe (diff) | |
| download | pbs2-e01348134e7d44de9471c4d76659cab41a6c9952.tar.gz pbs2-e01348134e7d44de9471c4d76659cab41a6c9952.tar.xz pbs2-e01348134e7d44de9471c4d76659cab41a6c9952.zip | |
Session und Filter fuer ipxe Bootmenu
Diffstat (limited to 'application/modules/ipxe/controllers/AuthController.php')
| -rw-r--r-- | application/modules/ipxe/controllers/AuthController.php | 124 |
1 files changed, 60 insertions, 64 deletions
diff --git a/application/modules/ipxe/controllers/AuthController.php b/application/modules/ipxe/controllers/AuthController.php index c553566..d3c5ca0 100644 --- a/application/modules/ipxe/controllers/AuthController.php +++ b/application/modules/ipxe/controllers/AuthController.php @@ -12,80 +12,76 @@ class Ipxe_AuthController extends Zend_Controller_Action { + protected $membership; public function init() { - $this->db = Zend_Db_Table::getDefaultAdapter(); - $this->personmapper = new Application_Model_PersonMapper(); - } + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); - public function indexAction() - { - $this->_helper-> viewRenderer-> setNoRender(); - $this->_helper->redirector('login', 'auth'); } - public function loginAction() + public function errorAction() { - if (Zend_Auth::getInstance()->hasIdentity()) { - $this->_redirect('/fbgui/'); - } else { - if (!isset($_POST["login"])){ - $loginForm = new fbgui_Form_Login(); - } else { - $loginForm = new fbgui_Form_Login($_POST); - - if ($loginForm->isValid($_POST)) { - - $auth = Zend_Auth::getInstance(); - - $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'pbs_person', 'email', 'password', 'MD5(CONCAT(?, password_salt))'); - - - $adapter->setIdentity($loginForm->getValue('email')); - $adapter->setCredential($loginForm->getValue('password')); - - $result = $auth->authenticate($adapter); - - // TODO: erweiterte fehlerbeschreibung des Users - - if ($result->isValid()) { - $this->personmapper = new Application_Model_PersonMapper(); - $result = $this->personmapper->findBy(array('email' => Zend_Auth::getInstance()->getIdentity()),true); - $person = new Application_Model_Person($result[0]); - $person->setID($result[0]['personID']); - $date = new DateTime(); - $person->setLogindate($date->getTimestamp()); - $this->personmapper->save($person); - $this->_helper->redirector('selectmembership', 'person'); - return; - } else { - echo "Wrong Email or Password."; - } - } - } - $this->view->loginForm = $loginForm; + $result = $this->_request->getParam('serialresult'); + if($result != ""){ + $pbsNotifier = new Pbs_Notifier(); + echo $pbsNotifier->notify('serial',$result); } } - public function logoutAction() + public function serialAction() { - $this->_helper-> viewRenderer-> setNoRender(); - $auth = Zend_Auth::getInstance(); - $auth->clearIdentity(); - Zend_Session::namespaceUnset('userIDs'); - Zend_Session::forgetMe(); - $this->_redirect('/fbgui/index'); -# $this->_helper->redirector('fbgui', 'index'); - return; + $serialnumber = $this->_request->getParam('serialnumber'); + $mac = $this->_request->getParam('mac'); + + if(isset($serialnumber)){ + // Create a session + + $n = new Pbs_Session(); + + $bootisomapper = new Application_Model_BootIsoMapper(); + $bootiso = new Application_Model_BootIso(); + + $results = $bootisomapper->findBy(array('serialnumber' => $serialnumber),true); + if(count($results) == 0){ + $this->_redirect('/ipxe/auth/error/serialresult/noserial'); + } + $bootiso->setOptions($results[0]); + $bootiso->setID($results[0]['bootisoID']); + $groupID = $bootiso->getGroupID(); + + $client = new Application_Model_Client(); + $client->setGroupID($groupID); + $client->setMacadress($mac); + $client->setCreated(time()); + $client = $n->createClient($client); + $clientID = $client->getID(); + + if(!isset($_SESSION['alphasessionID'])){ + $session = new Application_Model_Session(); + $session->setBootisoID($bootiso->getID()); + $session->setClientID($clientID); + $session->setTime(time()); + $session->setIp($_SERVER['REMOTE_ADDR']); + $session = $n->createSession($session); + $_SESSION['alphasessionID'] = $session->getAlphasessionID(); + } + else{ + $session = new Application_Model_Session(); + $sessionMapper = new Application_Model_SessionMapper(); + $sessions = $sessionMapper->findBy(array('alphasessionID'=>$_SESSION['alphasessionID'])); + $session = $sessions[0]; + } + + $this->_redirect('/ipxe/resource/ipxe/alpha/'.$session->getAlphasessionID()); + + } + else{ + + $this->_redirect('/ipxe/auth/error/serialresult/noserial'); + } + } + } - - - - - - - - - |
