extranet/application/controllers/UserController.php

49 lines
1.1 KiB
PHP
Raw Normal View History

2010-11-22 12:50:12 +00:00
<?php
require_once 'Web/forms/login.php';
require_once 'Web/WebAuthAdapter.php';
class UserController extends Zend_Controller_Action {
2011-01-05 09:59:49 +00:00
public function init()
{
$activeNav = $this->view->navigation();
$activeNav->removePages();
}
2010-11-22 12:50:12 +00:00
public function indexAction()
{
}
public function loginAction()
{
2010-11-24 10:55:21 +00:00
$this->view->headTitle()->append('Connexion');
2010-11-22 12:50:12 +00:00
$form = new Form_Login();
$this->view->form = $form;
$request = $this->getRequest();
if ($request->isPost()) {
$formData = $request->getPost ();
if ($form->isValid($formData)) {
$login = $form->getValue('login');
$pass = $form->getValue('pass');
$auth = Zend_Auth::getInstance();
$authAdapter = new WebAuthAdapter($login, $pass);
$result = $auth->authenticate($authAdapter);
if (!$result->isValid()){
$this->view->message = '';
foreach ($result->getMessages() as $message) {
$this->view->message.= $message."<br/>";
}
} else {
$this->_redirect('/');
}
}
}
}
public function logoutAction(){
Zend_Auth::getInstance()->clearIdentity();
}
}