44 lines
1.0 KiB
PHP
44 lines
1.0 KiB
PHP
|
<?php
|
||
|
require_once 'Web/forms/login.php';
|
||
|
require_once 'Web/WebAuthAdapter.php';
|
||
|
|
||
|
class UserController extends Zend_Controller_Action {
|
||
|
|
||
|
public function init(){}
|
||
|
|
||
|
public function indexAction()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
public function loginAction()
|
||
|
{
|
||
|
$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();
|
||
|
}
|
||
|
|
||
|
}
|