Bug correction with recent load method refactor

This commit is contained in:
Phyks 2013-08-29 12:26:28 +02:00
parent 73b772aa61
commit 17871b984c
4 changed files with 7 additions and 9 deletions

1
TODO
View File

@ -14,6 +14,7 @@ Manage paybacks :
TODO :
======
* Add / Edit a bill
* Bug in connection form
Tests :
=======

View File

@ -135,7 +135,7 @@ class Storage {
}
if($first_only)
return $return[0];
return $return[$result['id']];
else
return $return;
}

View File

@ -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;

View File

@ -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();