1 <?php
defined('SYSPATH') or die('No direct access allowed.');
4 * [!!] this Auth driver does not support roles nor autologin.
8 * @copyright (c) 2007-2010 Kohana Team
9 * @license http://kohanaframework.org/license
11 class Kohana_Auth_File
extends Auth
{
17 * Constructor loads the user list into the class.
19 public function __construct($config = array())
21 parent
::__construct($config);
24 $this->_users
= Arr
::get($config, 'users', array());
30 * @param string username
31 * @param string password
32 * @param boolean enable autologin (not supported)
35 protected function _login($username, $password, $remember)
37 if (is_string($password))
39 // Create a hashed password
40 $password = $this->hash($password);
43 if (isset($this->_users
[$username]) AND $this->_users
[$username] === $password)
46 return $this->complete_login($username);
54 * Forces a user to be logged in, without specifying a password.
56 * @param mixed username
59 public function force_login($username)
62 return $this->complete_login($username);
66 * Get the stored password for a username.
68 * @param mixed username
71 public function password($username)
73 return Arr
::get($this->_users
, $username, FALSE);
77 * Compare password with original (plain text). Works for current (logged in) user
79 * @param string $password
82 public function check_password($password)
84 $username = $this->get_user();
86 if ($username === FALSE)
91 return ($password === $this->password($username));