summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Geiger2011-08-04 11:43:25 +0200
committerBjörn Geiger2011-08-04 11:43:25 +0200
commitf010dc749dd75ed09be9967ad3dc0c7fb82d16da (patch)
tree4630ae5c7b31bea5d6f16012b1f551436eb04921
parentnew files (diff)
downloadpoolctrl-f010dc749dd75ed09be9967ad3dc0c7fb82d16da.tar.gz
poolctrl-f010dc749dd75ed09be9967ad3dc0c7fb82d16da.tar.xz
poolctrl-f010dc749dd75ed09be9967ad3dc0c7fb82d16da.zip
Login nun über LoginAPI des PBS
-rw-r--r--application/configs/application.ini.dist3
-rw-r--r--application/controllers/AuthController.php56
2 files changed, 32 insertions, 27 deletions
diff --git a/application/configs/application.ini.dist b/application/configs/application.ini.dist
index bd19e51..0852ec9 100644
--- a/application/configs/application.ini.dist
+++ b/application/configs/application.ini.dist
@@ -16,13 +16,14 @@ resources.db.isDefaultTableAdapter = true
resources.view[] = ""
resources.modules = ""
pbs2.host =
+pbs2.login = /resource/login/
pbs2.getbootoss = /resource/getbootos/apikey/
pbs2.getpools = /resource/getpool/apikey/
pbs2.addbootmenu = /resource/addbootmenu/apikey/
pbs2.deletebootmenu = /resource/deletebootmenu/apikey/
pbs2.addfilter = /resource/addfilter/apikey/
pbs2.deletefilter = /resource/deletefilter/apikey/
-
+
resources.layout.layout = "default"
resources.layout.layoutPath = APPLICATION_PATH "/layouts"
diff --git a/application/controllers/AuthController.php b/application/controllers/AuthController.php
index c34ce0c..0de5d67 100644
--- a/application/controllers/AuthController.php
+++ b/application/controllers/AuthController.php
@@ -14,16 +14,20 @@ class AuthController extends Zend_Controller_Action
{
protected $personmapper = null;
private $db = null;
+ protected $config;
+ protected $pbs2host;
public function init()
{
+ $bootstrap = $this->getInvokeArg('bootstrap');
+ $this->config = $bootstrap->getOptions();
+ $this->pbs2host = $this->config['pbs2']['host'];
$this->db = Zend_Db_Table::getDefaultAdapter();
$this->personmapper = new Application_Model_PersonMapper();
}
public function indexAction()
{
- $this->_helper-> viewRenderer-> setNoRender();
$this->_helper->redirector('login', 'auth');
}
@@ -38,35 +42,35 @@ class AuthController extends Zend_Controller_Action
$loginForm = new Application_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);
-
- 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]);
- print_a('case1',$person);
- $person->setID($result[0]['personID']);
- $date = new DateTime();
- $person->setLogindate($date->getTimestamp());
- if($person->getSuspend()) {
- $poolctrlNotifier = new Poolctrl_Notifier();
- $this->view->notification = $poolctrlNotifier->notify('Your Account is suspended', 'error');
- } else {
+ $loginquery = "email=" . $loginForm->getValue('email') . "&password=" . $loginForm->getValue('password');
+ $loginApiResult = PostToHost($this->pbs2host, $this->config['pbs2']['login'], 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'poolctrl', $loginquery);
+ $loginXMLString = $loginApiResult['http-body'];
+ if(strlen($loginXMLString) > 0) {
+ $loginXML = new SimpleXMLElement($loginXMLString);
+ $login = $loginXML->login;
+ $success = sprintf("%s", $login->success);
+ if ($success === "true") {
+ $personid = sprintf("%s", $login->personid);
+ $this->personmapper = new Application_Model_PersonMapper();
+ $person = $this->personmapper->find($personid);
+ print_a('case1',$person);
+ $date = new DateTime();
+ $person->setLogindate($date->getTimestamp());
$this->personmapper->save($person);
+ $authSession = new Zend_Session_Namespace('auth');
+ $authSession->storage = $person->getEmail();
$this->_helper->redirector('selectmembership', 'person');
return;
+ } else {
+ $error = sprintf("%s", $login->error);
+ if($error == "wrong email or password") {
+ $poolctrlNotifier = new Poolctrl_Notifier();
+ $this->view->notification = $poolctrlNotifier->notify('Wrong Email or Password', 'error');
+ } else if($error == "person suspended") {
+ $poolctrlNotifier = new Poolctrl_Notifier();
+ $this->view->notification = $poolctrlNotifier->notify('Your Account is suspended', 'error');
+ }
}
- } else {
- $poolctrlNotifier = new Poolctrl_Notifier();
- $this->view->notification = $poolctrlNotifier->notify('Wrong Email or Password', 'error');
}
}
}