| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/b2bzend/application/models/ |
Upload File : |
<?php
/**
* Digitalus CMS
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://digitalus-media.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to info@digitalus-media.com so we can send you a copy immediately.
*
* @category Digitalus CMS
* @package Digitalus_Core_Library
* @copyright Copyright (c) 2007 - 2008, Digitalus Media USA (digitalus-media.com)
* @license http://digitalus-media.com/license/new-bsd New BSD License
* @version $Id: Auth.php Tue Dec 25 21:40:32 EST 2007 21:40:32 forrest lyman $
*/
class Travel_Model_AdminAuth
{
/**
* auth adapter
*
* @var zend_auth_adapter
*/
private $_authAdapter;
private $_dbAdapter;
/**
* the passed username
*
* @var string
*/
private $_username;
/**
* the passed password
*
* @var string
*/
private $_password;
/**
* the user session storage
*
* @var zend_session_namespace
*/
private $_storage;
/**
* the table that contains the user credentials
*
* @var string
*/
protected $_userTable = "TB_Admin_User";
/**
* the indentity column
*
* @var string
*/
protected $_identityColumn = "UserName";
/**
* the credential column
*
* @var string
*/
protected $_credentialColumn = "Password";
const USER_NAMESPACE = 'AdminUser';
// protected $_resultRowColumns = array('id', 'user_group_id', 'first_name', 'last_name', 'email', 'role', 'acl_resources');
protected $_resultRowColumns = array('UserName', 'UserAccessLevelType', 'UserRole', 'EmailId','IsActive','IsMarkForDel','UserSysId','ContNo');
/**
* build the login request
*
* @param string $username
* @param string $password
*/
public function __construct($username = null, $password = null)
{
//set up the db authentication
// zend auth uses FETCH_ASSOC for the fetchmode
$this->_dbAdapter = clone (Zend_Db_Table::getDefaultAdapter());
$this->_dbAdapter->setFetchMode(zend_db::FETCH_ASSOC );
$this->_authAdapter = new Zend_Auth_Adapter_DbTable($this->_dbAdapter, $this->_userTable, $this->_identityColumn, $this->_credentialColumn);
$this->_username = $username;
$this->_password = $password;
//$this->_password = ($password);
//set up storage
// @todo: i can not get zend to persist the identities for some reason .. figure out why
$this->_storage = new Zend_Session_Namespace(self::USER_NAMESPACE);
}
/**
* authenticate the request
*
* @return zend_auth_response
*/
public function authenticate()
{
//authenticate the user
$this->_authAdapter->setIdentity($this->_username);
$this->_authAdapter->setCredential($this->_password);
$result = $this->_authAdapter->authenticate();
if ($result->isValid()) {
//save the user and return the result
$row = $this->_authAdapter->getResultRowObject($this->_resultRowColumns);
$this->_storage->user = $row;
return $result;
}
}
/**
* get the current user identity if it exists
*
* @return zend_auth_response
*/
public static function getIdentity()
{
$storage = new Zend_Session_Namespace(self::USER_NAMESPACE);
if (isset($storage->user)) {
return $storage->user;
}
}
/**
* destroys the current user session
*
*/
public static function destroy()
{
$storage = new Zend_Session_Namespace(self::USER_NAMESPACE);
$storage->unsetAll();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$sessionLogin_user->unsetAll();
unset($_SESSION['timeout']);
}
}