Updated to work with KH 3.1

This commit is contained in:
Deon George
2011-05-23 20:01:27 +10:00
parent 4765770a1a
commit a244d693b5
28 changed files with 1027 additions and 553 deletions

View File

@@ -3,7 +3,7 @@
/**
* This class overrides Kohana's Auth so that we can login to TSM
*
* @package PTA
* @package PTA/Modifications
* @subpackage Auth
* @category Overrides
* @author Deon George
@@ -11,19 +11,16 @@
* @license http://phptsmadmin.sf.net/license.html
*/
class Auth_ORM extends Kohana_Auth_ORM {
/**
* Attempt to log in a user by using an ORM object and plain-text password.
*
* @param string username to log in
* @param string password to check against
* @param boolean enable autologin
* @return boolean
*/
public function login($username, $password, $remember = FALSE) {
// With TSM, if we get this far, we are logged in
return $username->loaded();
// Override Kohana Auth requirement to have a hash_key
public function hash($str) {
switch ($this->_config['hash_method']) {
case '' : return $str;
case 'md5': return md5($str);
default: return hash_hmac($this->_config['hash_method'], $str, $this->_config['hash_key']);
}
}
// Override Kohana logged_in() - if we can get the user, we are logged in.
public function logged_in($role = NULL, $all_required = TRUE) {
return FALSE !== $this->get_user();
}

View File

@@ -0,0 +1,37 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* OSB Auth driver.
*
* @package PTA
* @subpackage Account
* @category Auth
* @author Deon George
* @copyright (c) phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Auth_TSM extends Auth_ORM {
/**
* Logs a user in.
*
* @param string username
* @param string password
* @param boolean enable autologin
* @return boolean
*/
protected function _login($user, $password, $remember) {
if ( ! is_object($user))
{
$username = $user;
// Load the user
$user = ORM::factory('admin')
->where('ADMIN_NAME','=',$username)
->find();
}
// Normally, if we get this far, we are already logged in.
return TRUE;
}
}
?>