aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
authorJoseph Warner <hardolaf@hardolaf.com>2013-06-18 16:07:23 -0400
committerJoseph Warner <hardolaf@hardolaf.com>2013-06-18 16:07:23 -0400
commit0432c3273992cf44b711fad92d442c81016a96c1 (patch)
treece42bdd0b6c52c1a06afa3116ec8be5833d754e9 /phpBB/includes
parent204c640c773e707845859d103b74d64596de402d (diff)
downloadforums-0432c3273992cf44b711fad92d442c81016a96c1.tar
forums-0432c3273992cf44b711fad92d442c81016a96c1.tar.gz
forums-0432c3273992cf44b711fad92d442c81016a96c1.tar.bz2
forums-0432c3273992cf44b711fad92d442c81016a96c1.tar.xz
forums-0432c3273992cf44b711fad92d442c81016a96c1.zip
[feature/auth-refactor] Make DB auth consistent with interface
Makes provider_db consistent with provider_interface. Removes $ip, $browser, and $forwarded_for from the arguments of phpbb_auth_provider_db::login() as these are provided by the global variable $user. PHPBB3-9734
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/auth/provider_db.php22
1 files changed, 9 insertions, 13 deletions
diff --git a/phpBB/includes/auth/provider_db.php b/phpBB/includes/auth/provider_db.php
index c55837c685..9e865f4b5b 100644
--- a/phpBB/includes/auth/provider_db.php
+++ b/phpBB/includes/auth/provider_db.php
@@ -34,10 +34,6 @@ class phpbb_auth_provider_db implements phpbb_auth_provider_interface
*
* @param string $username
* @param string $password
- * @param string $ip IP address the login is taking place from. Used to
- * limit the number of login attempts per IP address.
- * @param string $browser The user agent used to login
- * @param string $forwarded_for X_FORWARDED_FOR header sent with login request
* @return array A associative array of the format
* array(
* 'status' => status constant
@@ -45,10 +41,10 @@ class phpbb_auth_provider_db implements phpbb_auth_provider_interface
* 'user_row' => array
* )
*/
- public function login($username, $password, $ip = '', $browser = '', $forwarded_for = '')
+ public function login($username, $password)
{
global $db, $config;
- global $request;
+ global $request, $user;
// Auth plugins get the password untrimmed.
// For compatibility we trim() here.
@@ -82,19 +78,19 @@ class phpbb_auth_provider_db implements phpbb_auth_provider_interface
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
- if (($ip && !$config['ip_login_limit_use_forwarded']) ||
- ($forwarded_for && $config['ip_login_limit_use_forwarded']))
+ if (($user->ip && !$config['ip_login_limit_use_forwarded']) ||
+ ($user->forwarded_for && $config['ip_login_limit_use_forwarded']))
{
$sql = 'SELECT COUNT(*) AS attempts
FROM ' . LOGIN_ATTEMPT_TABLE . '
WHERE attempt_time > ' . (time() - (int) $config['ip_login_limit_time']);
if ($config['ip_login_limit_use_forwarded'])
{
- $sql .= " AND attempt_forwarded_for = '" . $db->sql_escape($forwarded_for) . "'";
+ $sql .= " AND attempt_forwarded_for = '" . $db->sql_escape($user->forwarded_for) . "'";
}
else
{
- $sql .= " AND attempt_ip = '" . $db->sql_escape($ip) . "' ";
+ $sql .= " AND attempt_ip = '" . $db->sql_escape($user->ip) . "' ";
}
$result = $db->sql_query($sql);
@@ -102,9 +98,9 @@ class phpbb_auth_provider_db implements phpbb_auth_provider_interface
$db->sql_freeresult($result);
$attempt_data = array(
- 'attempt_ip' => $ip,
- 'attempt_browser' => trim(substr($browser, 0, 149)),
- 'attempt_forwarded_for' => $forwarded_for,
+ 'attempt_ip' => $user->ip,
+ 'attempt_browser' => trim(substr($user->browser, 0, 149)),
+ 'attempt_forwarded_for' => $user->forwarded_for,
'attempt_time' => time(),
'user_id' => ($row) ? (int) $row['user_id'] : 0,
'username' => $username,