return false;
}
- if ($row =& $this->db->sql_fetchrow($dbresult)) {
+ $row = $this->db->sql_fetchrow($dbresult);
+ $this->db->sql_freeresult($dbresult);
+
+ if ($row) {
$id = $_SESSION[$this->getSessionKey()] = $row[$this->getFieldName('primary')];
if ($remember) {
$cookie = $id .':'. md5($username.$password);
setcookie($this->cookiekey, $cookie, time() + $this->cookietime, '/');
}
- $this->db->sql_freeresult($dbresult);
return true;
} else {
return false;
}
+
+ /**
+ * Delete all bookmarks.
+ * Mainly used in unit tests.
+ *
+ * @return void
+ */
+ public function deleteAll()
+ {
+ $query = 'TRUNCATE TABLE `'. $this->getTableName() .'`';
+ $this->db->sql_query($query);
+ }
+
+
+
function sanitisePassword($password) {
return sha1(trim($password));
}
$this->assertEquals($uid2, $user['uId']);
}
+
+
+ /**
+ * Test login() function with invalid creditentials
+ *
+ * @return void
+ */
+ public function testLoginInvalid()
+ {
+ $this->us->deleteAll();
+ $this->assertFalse(
+ $this->us->login('doesnot', 'exist', false)
+ );
+ }
+
}