X-Git-Url: https://dev.renevier.net/?a=blobdiff_plain;f=application%2Fcontrollers%2FLoginController.php;h=85c7ac1541a972c3966d5a6798146167531a2704;hb=0722c496ca63f30937427e3bf8fbdd5cfee2c83d;hp=48636214855fbcd672d941ab275c2201ed325565;hpb=1de0f433144272946051bb0df886b8c43459beb8;p=syj.git diff --git a/application/controllers/LoginController.php b/application/controllers/LoginController.php index 4863621..85c7ac1 100644 --- a/application/controllers/LoginController.php +++ b/application/controllers/LoginController.php @@ -1,16 +1,15 @@ view->headTitle($this->view->translate("login")); - $this->view->headScript()->appendFile('js/prototype.js'); - $this->view->headScript()->appendFile('js/utils.js'); - $this->view->headScript()->appendFile('js/login.js'); - $this->view->headLink()->appendStylesheet('css/generic.css'); - $this->view->headLink()->appendStylesheet('css/login.css'); + $this->_helper->SyjMedias->addScripts('login'); + $this->view->headLink()->appendStylesheet('css/generic.css', 'all'); + $this->view->headLink()->appendStylesheet('css/form.css', 'all'); + $this->view->headLink()->appendStylesheet('css/login.css', 'all'); } public function loginAction() { @@ -33,15 +32,7 @@ class LoginController extends Zend_Controller_Action } /* form has been filled */ - - $adapter = Zend_Db_Table_Abstract::getDefaultAdapter(); - $authAdapter = new Zend_Auth_Adapter_DbTable($adapter, 'users', 'pseudo', 'password'); - $authAdapter->setIdentity($formData['login_user']) - ->setCredential(sha1($formData['login_password'])); - - $auth = Zend_Auth::getInstance(); - $result = $auth->authenticate($authAdapter); - if (!$result->isValid()) { + if (!$this->_helper->SyjUserManager->validate($formData['login_user'], sha1($formData['login_password']))) { if ($httprequest) { throw new Syj_Exception_Forbidden(); } else { @@ -50,13 +41,11 @@ class LoginController extends Zend_Controller_Action } } - $userid = $authAdapter->getResultRowObject('id')->id; - $auth->getStorage()->write(array('user' => $userid)); - Zend_Session::rememberMe(); // zend default expiration delay is 2 weeks. Ok, use that value - + $user = $this->_helper->SyjUserManager->current(); if ($httprequest) { $api = $this->_helper->SyjApi->setCode(200); + $data = array('pseudo' => $user->pseudo); $login_geom_id = $formData['login_geom_id']; if ($login_geom_id) { @@ -65,22 +54,18 @@ class LoginController extends Zend_Controller_Action if (!$pathMapper->find((int)$login_geom_id, $path)) { throw new Syj_Exception_Request(); } - if ($path->owner->id === $userid) { - $api->setBody("1"); // owner of displayed geometry - } else { - $api->setBody("0"); - } + $data['iscreator'] = ($path->creator->id === $userid); } else { - $api->setBody("1"); // no geometry displayed: owner of the (future) geometry + $data['iscreator'] = true; } + $api->setBodyJson($data); } else { $this->redirect(); } } public function logoutAction() { - Zend_Session::start(); - Zend_Session::destroy(); + $this->_helper->SyjUserManager->logout(); $this->redirect(); }