summaryrefslogtreecommitdiffstats
path: root/application/modules/ipxe/controllers/AuthController.php
diff options
context:
space:
mode:
authormichael pereira2011-09-23 19:06:16 +0200
committermichael pereira2011-09-23 19:06:16 +0200
commit6d572a7654ac9717d8ad82ba4037c88b07855825 (patch)
tree5403908e6113f16d7aba8bc850e615a6329c4b61 /application/modules/ipxe/controllers/AuthController.php
parentkleiner fix (diff)
downloadpbs2-6d572a7654ac9717d8ad82ba4037c88b07855825.tar.gz
pbs2-6d572a7654ac9717d8ad82ba4037c88b07855825.tar.xz
pbs2-6d572a7654ac9717d8ad82ba4037c88b07855825.zip
login und selectmembership
Diffstat (limited to 'application/modules/ipxe/controllers/AuthController.php')
-rw-r--r--application/modules/ipxe/controllers/AuthController.php43
1 files changed, 41 insertions, 2 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.";
+ }
+ }
+
+
}