summaryrefslogtreecommitdiffstats
path: root/application/models
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2013-01-30 22:31:11 +0100
committerFlorian Pritz <bluewind@xinu.at>2013-01-30 22:31:11 +0100
commitf8ac2f6582001bfa3b42ac4fbdc77ff97137a8f8 (patch)
treecc6979a56bd458546582b7da3c69bf0ec5f8af82 /application/models
parente8d30fa25470f3912c0d4e8629fc7b764aae1c72 (diff)
Modularize authentication system
This allows to easily add LDAP and other support. Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/models')
-rw-r--r--application/models/muser.php40
1 files changed, 3 insertions, 37 deletions
diff --git a/application/models/muser.php b/application/models/muser.php
index c277118f2..d13e0662a 100644
--- a/application/models/muser.php
+++ b/application/models/muser.php
@@ -17,6 +17,7 @@ class Muser extends CI_Model {
}
$this->load->helper("filebin");
+ $this->load->driver("duser");
}
function has_session()
@@ -56,28 +57,7 @@ class Muser extends CI_Model {
function login($username, $password)
{
$this->require_session();
- $query = $this->db->query('
- SELECT username, id, password
- FROM `users`
- WHERE `username` = ?
- ', array($username))->row_array();
-
- if (!isset($query["username"]) || $query["username"] !== $username) {
- return false;
- }
-
- if (!isset($query["password"])) {
- return false;
- }
-
- if (crypt($password, $query["password"]) === $query["password"]) {
- $this->session->set_userdata('logged_in', true);
- $this->session->set_userdata('username', $username);
- $this->session->set_userdata('userid', $query["id"]);
- return true;
- } else {
- return false;
- }
+ return $this->duser->login($username, $password);
}
function logout()
@@ -127,21 +107,7 @@ class Muser extends CI_Model {
function username_exists($username)
{
- if ($username === false) {
- return false;
- }
-
- $query = $this->db->query("
- SELECT id
- FROM users
- WHERE username = ?
- ", array($username));
-
- if ($query->num_rows() > 0) {
- return true;
- } else {
- return false;
- }
+ return $this->duser->username_exists($username);
}
function get_action($action, $key)