From 17871b984c91c65a262228cefa7e0495994ea61b Mon Sep 17 00:00:00 2001 From: Phyks Date: Thu, 29 Aug 2013 12:26:28 +0200 Subject: [PATCH] Bug correction with recent load method refactor --- TODO | 1 + inc/Storage.class.php | 2 +- inc/User.class.php | 10 +++------- index.php | 3 ++- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/TODO b/TODO index e24475f..88f1b47 100755 --- a/TODO +++ b/TODO @@ -14,6 +14,7 @@ Manage paybacks : TODO : ====== * Add / Edit a bill +* Bug in connection form Tests : ======= diff --git a/inc/Storage.class.php b/inc/Storage.class.php index a82e103..c9b5bd7 100644 --- a/inc/Storage.class.php +++ b/inc/Storage.class.php @@ -135,7 +135,7 @@ class Storage { } if($first_only) - return $return[0]; + return $return[$result['id']]; else return $return; } diff --git a/inc/User.class.php b/inc/User.class.php index 361d373..4a94ecd 100644 --- a/inc/User.class.php +++ b/inc/User.class.php @@ -70,14 +70,10 @@ class User extends Storage { // Check if a user exists by login and load it // =========================================== public function exists() { - $user_data = $this->load(array('login'=>$this->login)); - if(count($user_data) == 1) { - $this->setId($user_data[0]['id']); - $this->setDisplayName($user_data[0]['display_name']); - $this->setAdmin($user_data[0]['admin']); - $this->setPassword($user_data[0]['password']); + $user_data = $this->load(array('login'=>$this->login), true); - return true; + if(count($user_data) == 1) { + return $user_data; } else { return false; diff --git a/index.php b/index.php index d3b2556..e039b0f 100644 --- a/index.php +++ b/index.php @@ -77,7 +77,8 @@ $error = "Unknown username / password."; } else { - if($user->exists($_POST['login']) && $user->checkPassword($_POST['password'])) { + $user = $user->exists($_POST['login']); + if($user !== false && $user->checkPassword($_POST['password'])) { ban_loginOk(); $_SESSION['current_user'] = $user->sessionStore(); $_SESSION['ip'] = user_ip();