diff options
| author | michael pereira | 2011-09-23 19:06:16 +0200 |
|---|---|---|
| committer | michael pereira | 2011-09-23 19:06:16 +0200 |
| commit | 6d572a7654ac9717d8ad82ba4037c88b07855825 (patch) | |
| tree | 5403908e6113f16d7aba8bc850e615a6329c4b61 /application/modules/ipxe/controllers | |
| parent | kleiner fix (diff) | |
| download | pbs2-6d572a7654ac9717d8ad82ba4037c88b07855825.tar.gz pbs2-6d572a7654ac9717d8ad82ba4037c88b07855825.tar.xz pbs2-6d572a7654ac9717d8ad82ba4037c88b07855825.zip | |
login und selectmembership
Diffstat (limited to 'application/modules/ipxe/controllers')
| -rw-r--r-- | application/modules/ipxe/controllers/AuthController.php | 43 | ||||
| -rw-r--r-- | application/modules/ipxe/controllers/ResourceController.php | 93 |
2 files changed, 101 insertions, 35 deletions
diff --git a/application/modules/ipxe/controllers/AuthController.php b/application/modules/ipxe/controllers/AuthController.php index 5434a59..5a406b0 100644 --- a/application/modules/ipxe/controllers/AuthController.php +++ b/application/modules/ipxe/controllers/AuthController.php @@ -18,6 +18,7 @@ class Ipxe_AuthController extends Zend_Controller_Action { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); + $this->db = Zend_Db_Table::getDefaultAdapter(); } @@ -29,7 +30,7 @@ class Ipxe_AuthController extends Zend_Controller_Action echo $pbsNotifier->notify('serial',$result); } } - + public function serialAction() { $serialnumber = $this->_request->getParam('serialnumber'); @@ -72,10 +73,11 @@ class Ipxe_AuthController extends Zend_Controller_Action $result .= "imgfree\n"; if($login){ $result .= "login\n"; - $result .= "chain http://".$_SERVER['HTTP_HOST']."/ipxe/vesamenu.c32 http://\${username:uristring}:\${password:uristring}@".$_SERVER['HTTP_HOST']."/ipxe/resource/getvesamenuconfig/alpha/".$session->getAlphasessionID()."/login/true\n"; + $result .= "chain http://\${username:uristring}:\${password:uristring}@".$_SERVER['HTTP_HOST']."/ipxe/auth/login/alpha/".$session->getAlphasessionID()."/login/true\n"; }else{ $result .= "chain http://".$_SERVER['HTTP_HOST']."/ipxe/vesamenu.c32 http://".$_SERVER['HTTP_HOST']."/ipxe/resource/getvesamenuconfig/alpha/".$session->getAlphasessionID()."/login/false\n"; } + header("Content-Length: ".(strlen($result))); @@ -89,4 +91,41 @@ class Ipxe_AuthController extends Zend_Controller_Action } + public function loginAction() + { + $alpha = $this->_request->getParam('alpha'); + + if(!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])){ + header('WWW-Authenticate: Basic realm=""'); + header('HTTP/1.0 401 Unauthorized'); + exit; + } + + $email = $_SERVER['PHP_AUTH_USER']; + $password = $_SERVER['PHP_AUTH_PW']; + + $auth = Zend_Auth::getInstance(); + $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'pbs_person', 'email', 'password', 'MD5(CONCAT(?, password_salt))'); + $adapter->setIdentity($email); + $adapter->setCredential($password); + + $result = $auth->authenticate($adapter); + + if ($result->isValid()) { + $personmapper = new Application_Model_PersonMapper(); + $result = $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()); + $personmapper->save($person); + + $this->_redirect("/ipxe/resource/getvesamenuconfig/alpha/".$alpha."/person/".$person->getID()."/login/true"); + return; + } else { + echo "Wrong Email or Password."; + } + } + + } diff --git a/application/modules/ipxe/controllers/ResourceController.php b/application/modules/ipxe/controllers/ResourceController.php index feb85d2..840505d 100644 --- a/application/modules/ipxe/controllers/ResourceController.php +++ b/application/modules/ipxe/controllers/ResourceController.php @@ -17,6 +17,16 @@ class Ipxe_ResourceController extends Zend_Controller_Action public function init() { + + if (Zend_Auth::getInstance()->hasIdentity()) { + $this->personmapper = new Application_Model_PersonMapper(); + $result = $this->personmapper->findBy(array('email' => Zend_Auth::getInstance()->getIdentity()),true); + $this->person = new Application_Model_Person($result[0]); + $this->person->setID($result[0]['personID']); + $this->membershipMapper = new Application_Model_MembershipMapper(); + $this->memberships = $this->membershipMapper->findBy(array("personID" => $this->person->getID()),true); + } + $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); @@ -91,15 +101,12 @@ class Ipxe_ResourceController extends Zend_Controller_Action public function getvesamenuconfigAction(){ - $login = $this->_request->getParam('login') == 'true'; - if($login){ - if(!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])){ - header('WWW-Authenticate: Basic realm=""'); - header('HTTP/1.0 401 Unauthorized'); - exit; - } - } +// $membershipMapper = new Application_Model_MembershipMapper(); +// $memberships = $membershipMapper->findBy(array("personID" => $person->getID()),true); +// + + header('Content-Type: text/html'); $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; header('Content-Disposition: ' . $content_disp . '; filename="vesamenu.conf"'); @@ -108,34 +115,54 @@ class Ipxe_ResourceController extends Zend_Controller_Action $vesamenuView = new Zend_View(); $vesamenuView->addScriptPath(APPLICATION_PATH.'/modules/ipxe/views/scripts/resource/'); - if($login == 'true'){ - $vesamenuView->username = $_SERVER['PHP_AUTH_USER']; - $vesamenuView->password = $_SERVER['PHP_AUTH_PW']; - } - $vesamenuView->login = $login; + $vesamenuView->host = $_SERVER['HTTP_HOST']; - $_SESSION['alphasessionID'] = $this->thisSession->getAlphasessionID(); - // Request Bootmenu - $pbsFilter = new Pbs_Filter(); - $bootmenuID = $pbsFilter->evaluate(); - - if($bootmenuID != null){ - $vesamenuView->alphaID = $this->thisSession->getAlphasessionID(); - - $bootmenuMapper = new Application_Model_BootMenuMapper(); - $bm = $bootmenuMapper->find($bootmenuID); - $vesamenuView->title = $bm->getTitle(); -// $this->view->startcounter = $bm->getStartcounter(); - - $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); - $res = $bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID),false); - $vesamenuView->bmelist = $res; + $login = $this->_request->getParam('login') == 'true'; + + if($login){ + $groupMapper = new Application_Model_GroupMapper(); + $roleMapper = new Application_Model_RoleMapper(); + if(isset($this->memberships)) { - } - else{ - - $vesamenuView->error = "You have no BootMenu."; + foreach($this->memberships as $membership) { + $group = $groupMapper->find($membership['groupID']); + $role = $roleMapper->find($membership['roleID']); + $membershipList[] = array( + 'membershipID' => $membership['membershipID'], + 'group' => $group->getTitle(), + 'role' => $role->getTitle() + ); + } + } + + $vesamenuView->action = "selectmembership"; + $vesamenuView->memberships = $membershipList; + + }else{ + $vesamenuView->login = $login; + $_SESSION['alphasessionID'] = $this->thisSession->getAlphasessionID(); + // Request Bootmenu + $pbsFilter = new Pbs_Filter(); + $bootmenuID = $pbsFilter->evaluate(); + + if($bootmenuID != null){ + $vesamenuView->alphaID = $this->thisSession->getAlphasessionID(); + + $bootmenuMapper = new Application_Model_BootMenuMapper(); + $bm = $bootmenuMapper->find($bootmenuID); + $vesamenuView->title = $bm->getTitle(); + // $this->view->startcounter = $bm->getStartcounter(); + + $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); + $res = $bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID),false); + $vesamenuView->bmelist = $res; + + } + else{ + + $vesamenuView->error = "You have no BootMenu."; + } } $vesamenu = $vesamenuView->render('getvesamenu.phtml'); |
