Source for file UserController.php
Documentation is available at UserController.php
* Controller class for managing user actions.
* @author Margus Sellin <margus@bitweb.ee>
* @copyright Copyright (C) 2011. All rights reserved. Margus Sellin
* User inserts his/her username and password into form and based on
* their validity he/she is being logged in or informed with the error
$this->view->form =
$form;
if($this->_request->isPost()) {
if($form->isValid($this->_request->getPost())) {
$username =
$this->_getParam('username');
$password =
$this->_getParam('password');
$this->_helper->redirector('index', 'admin');
$this->view->error =
'Sisselogimine ebaõnnestus. Palun kontrollige andmeid.';
* Verifies whether the parameters given by the user are valid or not by
* checking their existance in database.
* @param string $username User's username
* @param string $password User's password
* @return boolean $isValid Authentication result
$modelUser =
new Model_Kasutaja();
$auth =
Zend_Auth::getInstance();
$dbAdapter =
$modelUser->getAdapter();
$authAdapter =
new Zend_Auth_Adapter_DbTable($dbAdapter);
$authAdapter->setTableName('kasutaja')
->setIdentityColumn('Kasutajanimi')
->setCredentialColumn('Parool');
$authAdapter->setIdentity($username);
$authAdapter->setCredential(md5($password));
$result =
$auth->authenticate($authAdapter);
$isValid =
$result->isValid();
$userData =
$modelUser->fetchRow('Kasutajanimi=' .
$dbAdapter->quote($username));
$auth->getStorage()->write($userData);
* Logs out the current user by clearing his/her identity in Zend_Auth instance.
$auth =
Zend_Auth::getInstance();
$this->_helper->redirector('index', 'index');
Documentation generated on Wed, 15 Jun 2011 15:50:40 +0300 by phpDocumentor 1.4.1