extranet/application/controllers/IndexController.php
2011-01-10 10:19:09 +00:00

61 lines
1.6 KiB
PHP

<?php
class IndexController extends Zend_Controller_Action
{
protected $appConfig;
public function init()
{
/* Initialize action controller here */
}
public function preDispatch()
{
/*
* A placer dans un plugin en preDispatch dans le frontcontroller
* avec mémorisation de l'url d'appel
*
*/
$auth = Zend_Auth::getInstance();
if (!$auth->hasIdentity()){
$request = $this->getRequest();
if(count($request->getParams)>0){
$action = $request->getParam('action');
$login = $request->getParam('login');
$pass = $request->getParam('pass');
$checkIp = ($request->getParam('checkIp', '')=='only') ? true : false;
if ($checkIp){
$auth = Zend_Auth::getInstance();
$authAdapter = new WebAuthAdapter($login, $pass, $checkIp);
$result = $auth->authenticate($authAdapter);
if (!$result->isValid()){
$this->view->message = '';
foreach ($result->getMessages() as $message) {
$this->view->message.= $message."<br/>";
}
} else {
$timeout = $auth->getIdentity()->timeout;
$storage = new Zend_Auth_Storage_Session();
$sessionNamespace = new Zend_Session_Namespace($storage->getNamespace());
$sessionNamespace->setExpirationSeconds($timeout);
$auth->setStorage($storage);
$this->_redirect('/');
}
}
}
$this->_redirect('/user/login');
} else {
$bootstrap = $this->getInvokeArg('bootstrap');
$this->appConfig = $bootstrap->getOptions();
}
}
public function indexAction()
{
$this->_forward('entreprise', 'recherche');
}
}