1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-08 18:05:17 +02:00

Merge branch '3.2.x'

This commit is contained in:
Marc Alexander 2019-04-17 21:24:59 +02:00
commit 61b199aefb
No known key found for this signature in database
GPG Key ID: 50E0D2423696F995
4 changed files with 37 additions and 6 deletions

View File

@ -1942,9 +1942,9 @@ function validate_user_email($email, $allowed_email = false)
return $validate_email;
}
if (($ban_reason = $user->check_ban(false, false, $email, true)) !== false)
if (($ban = $user->check_ban(false, false, $email, true)) !== false)
{
return ($ban_reason === true) ? 'EMAIL_BANNED' : $ban_reason;
return ($ban === true) ? 'EMAIL_BANNED' : (!empty($ban['ban_give_reason']) ? $ban['ban_give_reason'] : $ban);
}
if (!$config['allow_emailreuse'])

View File

@ -191,7 +191,7 @@ class oauth extends \phpbb\auth\provider\base
return $provider->login($username, $password);
}
// Requst the name of the OAuth service
// Request the name of the OAuth service
$service_name_original = $this->request->variable('oauth_service', '', false);
$service_name = 'auth.provider.oauth.service.' . strtolower($service_name_original);
if ($service_name_original === '' || !array_key_exists($service_name, $this->service_providers))
@ -276,6 +276,31 @@ class oauth extends \phpbb\auth\provider\base
throw new \Exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_ENTRY');
}
/**
* Check if the user is banned.
* The fourth parameter, return, has to be true,
* otherwise the OAuth login is still called and
* an uncaught exception is thrown as there is no
* token stored in the database.
*/
$ban = $this->user->check_ban($row['user_id'], $row['user_ip'], $row['user_email'], true);
if (!empty($ban))
{
$till_date = !empty($ban['ban_end']) ? $this->user->format_date($ban['ban_end']) : '';
$message = !empty($ban['ban_end']) ? 'BOARD_BAN_TIME' : 'BOARD_BAN_PERM';
$contact_link = phpbb_get_board_contact_link($this->config, $this->phpbb_root_path, $this->php_ext);
$message = $this->user->lang($message, $till_date, '<a href="' . $contact_link . '">', '</a>');
$message .= !empty($ban['ban_give_reason']) ? '<br /><br />' . $this->user->lang('BOARD_BAN_REASON', $ban['ban_give_reason']) : '';
$message .= !empty($ban['ban_triggered_by']) ? '<br /><br /><em>' . $this->user->lang('BAN_TRIGGERED_BY_' . strtoupper($ban['ban_triggered_by'])) . '</em>' : '';
return array(
'status' => LOGIN_BREAK,
'error_msg' => $message,
'user_row' => $row,
);
}
// Update token storage to store the user_id
$storage->set_user_id($row['user_id']);
@ -714,7 +739,7 @@ class oauth extends \phpbb\auth\provider\base
AND user_id = " . (int) $user_id;
$this->db->sql_query($sql);
// Clear all tokens belonging to the user on this servce
// Clear all tokens belonging to the user on this service
$service_name = 'auth.provider.oauth.service.' . strtolower($link_data['oauth_service']);
$storage = new \phpbb\auth\provider\oauth\token_storage($this->db, $this->user, $this->auth_provider_oauth_token_storage_table, $this->auth_provider_oauth_state_table);
$storage->clearToken($service_name);

View File

@ -1301,7 +1301,12 @@ class session
trigger_error($message);
}
return ($banned && $ban_row['ban_give_reason']) ? $ban_row['ban_give_reason'] : $banned;
if (!empty($ban_row))
{
$ban_row['ban_triggered_by'] = $ban_triggered_by;
}
return ($banned && $ban_row) ? $ban_row : $banned;
}
/**

View File

@ -73,7 +73,8 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case
{
try
{
$is_banned = $this->session->check_ban($user_id, $user_ips, $user_email, $return);
$ban = $this->session->check_ban($user_id, $user_ips, $user_email, $return);
$is_banned = !empty($ban);
}
catch (PHPUnit\Framework\Error\Notice $e)
{