Updated to KH 3.3 and improved

This commit is contained in:
Deon George
2013-04-13 16:17:56 +10:00
parent 6f50463ec7
commit 6f7913d363
1551 changed files with 96188 additions and 29813 deletions

View File

@@ -0,0 +1,3 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
abstract class Auth extends Kohana_Auth { }

View File

@@ -0,0 +1,3 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
class Auth_File extends Kohana_Auth_File { }

View File

@@ -1,11 +1,11 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* User authorization library. Handles user login and logout, as well as secure
* password hashing.
*
* @package Kohana/Auth
* @author Kohana Team
* @copyright (c) 2007-2010 Kohana Team
* @copyright (c) 2007-2012 Kohana Team
* @license http://kohanaframework.org/license
*/
abstract class Kohana_Auth {
@@ -23,7 +23,7 @@ abstract class Kohana_Auth {
if ( ! isset(Auth::$_instance))
{
// Load the configuration for this type
$config = Kohana::config('auth');
$config = Kohana::$config->load('auth');
if ( ! $type = $config->get('driver'))
{
@@ -47,6 +47,7 @@ abstract class Kohana_Auth {
/**
* Loads Session and configuration options.
*
* @param array $config Config Options
* @return void
*/
public function __construct($config = array())
@@ -54,7 +55,7 @@ abstract class Kohana_Auth {
// Save the config in the object
$this->_config = $config;
$this->_session = Session::instance();
$this->_session = Session::instance($this->_config['session_type']);
}
abstract protected function _login($username, $password, $remember);
@@ -67,6 +68,7 @@ abstract class Kohana_Auth {
* Gets the currently logged in user from the session.
* Returns NULL if no user is currently logged in.
*
* @param mixed $default Default value to return if the user is currently not logged in.
* @return mixed
*/
public function get_user($default = NULL)
@@ -77,9 +79,9 @@ abstract class Kohana_Auth {
/**
* 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
* @param string $username Username to log in
* @param string $password Password to check against
* @param boolean $remember Enable autologin
* @return boolean
*/
public function login($username, $password, $remember = FALSE)
@@ -87,20 +89,14 @@ abstract class Kohana_Auth {
if (empty($password))
return FALSE;
if (is_string($password))
{
// Create a hashed password
$password = $this->hash($password);
}
return $this->_login($username, $password, $remember);
}
/**
* Log out a user by removing the related session variables.
*
* @param boolean completely destroy the session
* @param boolean remove all tokens for user
* @param boolean $destroy Completely destroy the session
* @param boolean $logout_all Remove all tokens for user
* @return boolean
*/
public function logout($destroy = FALSE, $logout_all = FALSE)
@@ -127,7 +123,7 @@ abstract class Kohana_Auth {
* Check if there is an active session. Optionally allows checking for a
* specific role.
*
* @param string role name
* @param string $role role name
* @return mixed
*/
public function logged_in($role = NULL)
@@ -140,7 +136,7 @@ abstract class Kohana_Auth {
* method is deprecated, [Auth::hash] should be used instead.
*
* @deprecated
* @param string plaintext password
* @param string $password Plaintext password
*/
public function hash_password($password)
{
@@ -150,7 +146,7 @@ abstract class Kohana_Auth {
/**
* Perform a hmac hash, using the configured method.
*
* @param string string to hash
* @param string $str string to hash
* @return string
*/
public function hash($str)

View File

@@ -1,11 +1,11 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* File Auth driver.
* [!!] this Auth driver does not support roles nor autologin.
*
* @package Kohana/Auth
* @author Kohana Team
* @copyright (c) 2007-2010 Kohana Team
* @copyright (c) 2007-2012 Kohana Team
* @license http://kohanaframework.org/license
*/
class Kohana_Auth_File extends Auth {
@@ -27,13 +27,19 @@ class Kohana_Auth_File extends Auth {
/**
* Logs a user in.
*
* @param string username
* @param string password
* @param boolean enable autologin (not supported)
* @param string $username Username
* @param string $password Password
* @param boolean $remember Enable autologin (not supported)
* @return boolean
*/
protected function _login($username, $password, $remember)
{
if (is_string($password))
{
// Create a hashed password
$password = $this->hash($password);
}
if (isset($this->_users[$username]) AND $this->_users[$username] === $password)
{
// Complete the login
@@ -47,7 +53,7 @@ class Kohana_Auth_File extends Auth {
/**
* Forces a user to be logged in, without specifying a password.
*
* @param mixed username
* @param mixed $username Username
* @return boolean
*/
public function force_login($username)
@@ -59,7 +65,7 @@ class Kohana_Auth_File extends Auth {
/**
* Get the stored password for a username.
*
* @param mixed username
* @param mixed $username Username
* @return string
*/
public function password($username)
@@ -70,7 +76,7 @@ class Kohana_Auth_File extends Auth {
/**
* Compare password with original (plain text). Works for current (logged in) user
*
* @param string $password
* @param string $password Password
* @return boolean
*/
public function check_password($password)
@@ -85,4 +91,4 @@ class Kohana_Auth_File extends Auth {
return ($password === $this->password($username));
}
} // End Auth File
} // End Auth File

View File

@@ -1,3 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
abstract class Auth extends Kohana_Auth { }

View File

@@ -1,3 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
class Auth_File extends Kohana_Auth_File { }