2010-09-13 09:03:55 +00:00
|
|
|
<?php
|
|
|
|
class UserController extends Zend_Controller_Action {
|
|
|
|
|
2010-12-07 16:18:12 +00:00
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
$activeNav = $this->view->navigation();
|
|
|
|
$activeNav->removePages();
|
|
|
|
}
|
2010-09-13 09:03:55 +00:00
|
|
|
|
|
|
|
public function indexAction()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function loginAction()
|
|
|
|
{
|
2013-09-22 17:38:05 +00:00
|
|
|
$this->_helper->layout()->disableLayout();
|
|
|
|
|
|
|
|
$this->view->headLink()
|
|
|
|
->appendStylesheet('/themes/default/css/signin.css', 'all');
|
|
|
|
|
|
|
|
$this->view->headTitle()->append('Connexion');
|
2013-05-21 13:12:53 +00:00
|
|
|
$form = new Application_Form_Login();
|
2010-09-13 09:03:55 +00:00
|
|
|
$this->view->form = $form;
|
|
|
|
$request = $this->getRequest();
|
|
|
|
if ($request->isPost()) {
|
2013-09-22 17:38:05 +00:00
|
|
|
$formData = $request->getPost();
|
2010-09-13 09:03:55 +00:00
|
|
|
if ($form->isValid($formData)) {
|
|
|
|
$login = $form->getValue('login');
|
|
|
|
$pass = $form->getValue('pass');
|
|
|
|
$auth = Zend_Auth::getInstance();
|
2013-11-21 08:59:32 +00:00
|
|
|
$authAdapter = new Scores_Auth_Adapter_Db($login, $pass, true);
|
2010-09-13 09:03:55 +00:00
|
|
|
$result = $auth->authenticate($authAdapter);
|
|
|
|
if (!$result->isValid()){
|
|
|
|
$this->view->message = '';
|
|
|
|
foreach ($result->getMessages() as $message) {
|
|
|
|
$this->view->message.= $message."<br/>";
|
|
|
|
}
|
|
|
|
} else {
|
2011-08-30 12:08:07 +00:00
|
|
|
$timeout = $auth->getIdentity()->timeout;
|
2012-05-20 13:11:13 +00:00
|
|
|
|
2011-08-30 12:08:07 +00:00
|
|
|
//Ecrit un cookie persistant valide pendant le temps definit
|
|
|
|
Zend_Session::rememberMe($timeout);
|
2012-05-20 13:11:13 +00:00
|
|
|
|
2011-08-30 12:08:07 +00:00
|
|
|
$storage = new Zend_Auth_Storage_Session();
|
|
|
|
$sessionNamespace = new Zend_Session_Namespace($storage->getNamespace());
|
|
|
|
$sessionNamespace->setExpirationSeconds($timeout);
|
|
|
|
$auth->setStorage($storage);
|
|
|
|
$url = '';
|
|
|
|
if (Zend_Session::namespaceIsset('login')){
|
|
|
|
$session = new Zend_Session_Namespace('login');
|
|
|
|
if (isset($session->url)) {
|
|
|
|
$url = $session->url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!empty($url)){
|
|
|
|
$this->_redirect($url);
|
2011-01-11 09:11:54 +00:00
|
|
|
}
|
2012-05-20 13:11:13 +00:00
|
|
|
|
2010-09-13 09:03:55 +00:00
|
|
|
$this->_redirect('/');
|
|
|
|
}
|
2012-05-20 13:11:13 +00:00
|
|
|
|
2010-09-13 09:03:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-11 09:11:54 +00:00
|
|
|
public function logoutAction()
|
|
|
|
{
|
2013-09-22 17:38:05 +00:00
|
|
|
$this->_helper->layout()->disableLayout();
|
2010-09-13 09:03:55 +00:00
|
|
|
Zend_Auth::getInstance()->clearIdentity();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|