mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[feature/auth-refactor] Refactor code to use services
Refactors all loading of auth providers to use services instead of directly calling the class. PHPBB3-9734
This commit is contained in:
parent
95f38b457e
commit
b8610c4b98
3 changed files with 24 additions and 40 deletions
|
@ -546,10 +546,9 @@ class acp_board
|
||||||
{
|
{
|
||||||
if ($method)
|
if ($method)
|
||||||
{
|
{
|
||||||
$class = 'phpbb_auth_provider_' . $method;
|
$provider = $phpbb_container->get('auth.provider.' . $method);
|
||||||
if (class_exists($class))
|
if ($provider)
|
||||||
{
|
{
|
||||||
$provider = new $class();
|
|
||||||
if ($fields = $provider->acp($this->new_config))
|
if ($fields = $provider->acp($this->new_config))
|
||||||
{
|
{
|
||||||
// Check if we need to create config fields for this plugin and save config when submit was pressed
|
// Check if we need to create config fields for this plugin and save config when submit was pressed
|
||||||
|
@ -586,10 +585,9 @@ class acp_board
|
||||||
$method = basename($cfg_array['auth_method']);
|
$method = basename($cfg_array['auth_method']);
|
||||||
if ($method)
|
if ($method)
|
||||||
{
|
{
|
||||||
$class = 'phpbb_auth_provider_' . $method;
|
$provider = $phpbb_container->get('auth.provider.' . $method);
|
||||||
if (class_exists($class))
|
if ($provider)
|
||||||
{
|
{
|
||||||
$provider = new $class();
|
|
||||||
if ($error = $provider->init())
|
if ($error = $provider->init())
|
||||||
{
|
{
|
||||||
foreach ($old_auth_config as $config_name => $config_value)
|
foreach ($old_auth_config as $config_name => $config_value)
|
||||||
|
@ -685,10 +683,9 @@ class acp_board
|
||||||
{
|
{
|
||||||
if ($method)
|
if ($method)
|
||||||
{
|
{
|
||||||
$class = 'phpbb_auth_provider_' . $method;
|
$provider = $phpbb_container->get('auth.provider.' . $method);
|
||||||
if (class_exists($class))
|
if ($provider)
|
||||||
{
|
{
|
||||||
$provider = new $class();
|
|
||||||
$fields = $provider->acp($this->new_config);
|
$fields = $provider->acp($this->new_config);
|
||||||
|
|
||||||
if ($fields['tpl'])
|
if ($fields['tpl'])
|
||||||
|
|
|
@ -927,14 +927,13 @@ class phpbb_auth
|
||||||
*/
|
*/
|
||||||
function login($username, $password, $autologin = false, $viewonline = 1, $admin = 0)
|
function login($username, $password, $autologin = false, $viewonline = 1, $admin = 0)
|
||||||
{
|
{
|
||||||
global $config, $db, $user, $phpbb_root_path, $phpEx;
|
global $config, $db, $user, $phpbb_root_path, $phpEx, $phpbb_container;
|
||||||
|
|
||||||
$method = trim(basename($config['auth_method']));
|
$method = trim(basename($config['auth_method']));
|
||||||
|
|
||||||
$class = 'phpbb_auth_provider_' . $method;
|
$provider = $phpbb_container->get('auth.provider.' . $method);
|
||||||
if (class_exists($class))
|
if ($provider)
|
||||||
{
|
{
|
||||||
$provider = new $class();
|
|
||||||
$login = $provider->login($username, $password);
|
$login = $provider->login($username, $password);
|
||||||
|
|
||||||
// If the auth module wants us to create an empty profile do so and then treat the status as LOGIN_SUCCESS
|
// If the auth module wants us to create an empty profile do so and then treat the status as LOGIN_SUCCESS
|
||||||
|
|
|
@ -207,7 +207,7 @@ class phpbb_session
|
||||||
function session_begin($update_session_page = true)
|
function session_begin($update_session_page = true)
|
||||||
{
|
{
|
||||||
global $phpEx, $SID, $_SID, $_EXTRA_URL, $db, $config, $phpbb_root_path;
|
global $phpEx, $SID, $_SID, $_EXTRA_URL, $db, $config, $phpbb_root_path;
|
||||||
global $request;
|
global $request, $phpbb_container;
|
||||||
|
|
||||||
// Give us some basic information
|
// Give us some basic information
|
||||||
$this->time_now = time();
|
$this->time_now = time();
|
||||||
|
@ -403,16 +403,12 @@ class phpbb_session
|
||||||
// Check whether the session is still valid if we have one
|
// Check whether the session is still valid if we have one
|
||||||
$method = basename(trim($config['auth_method']));
|
$method = basename(trim($config['auth_method']));
|
||||||
|
|
||||||
$class = 'phpbb_auth_provider_' . $method;
|
$provider = $phpbb_container->get('auth.provider.' . $method);
|
||||||
if (class_exists($class))
|
|
||||||
{
|
|
||||||
$provider = new $class();
|
|
||||||
$ret = $provider->validate_session($this->data);
|
$ret = $provider->validate_session($this->data);
|
||||||
if ($ret !== null && !$ret)
|
if ($ret !== null && !$ret)
|
||||||
{
|
{
|
||||||
$session_expired = true;
|
$session_expired = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!$session_expired)
|
if (!$session_expired)
|
||||||
{
|
{
|
||||||
|
@ -505,7 +501,7 @@ class phpbb_session
|
||||||
*/
|
*/
|
||||||
function session_create($user_id = false, $set_admin = false, $persist_login = false, $viewonline = true)
|
function session_create($user_id = false, $set_admin = false, $persist_login = false, $viewonline = true)
|
||||||
{
|
{
|
||||||
global $SID, $_SID, $db, $config, $cache, $phpbb_root_path, $phpEx;
|
global $SID, $_SID, $db, $config, $cache, $phpbb_root_path, $phpEx, $phpbb_container;
|
||||||
|
|
||||||
$this->data = array();
|
$this->data = array();
|
||||||
|
|
||||||
|
@ -570,10 +566,7 @@ class phpbb_session
|
||||||
|
|
||||||
$method = basename(trim($config['auth_method']));
|
$method = basename(trim($config['auth_method']));
|
||||||
|
|
||||||
$class = 'phpbb_auth_provider_' . $method;
|
$provider = $phpbb_container->get('auth.provider.' . $method);
|
||||||
if (class_exists($class))
|
|
||||||
{
|
|
||||||
$provider = new $class();
|
|
||||||
$this->data = $provider->autologin();
|
$this->data = $provider->autologin();
|
||||||
|
|
||||||
if (sizeof($this->data))
|
if (sizeof($this->data))
|
||||||
|
@ -581,7 +574,6 @@ class phpbb_session
|
||||||
$this->cookie_data['k'] = '';
|
$this->cookie_data['k'] = '';
|
||||||
$this->cookie_data['u'] = $this->data['user_id'];
|
$this->cookie_data['u'] = $this->data['user_id'];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// If we're presented with an autologin key we'll join against it.
|
// If we're presented with an autologin key we'll join against it.
|
||||||
// Else if we've been passed a user_id we'll grab data based on that
|
// Else if we've been passed a user_id we'll grab data based on that
|
||||||
|
@ -885,7 +877,7 @@ class phpbb_session
|
||||||
*/
|
*/
|
||||||
function session_kill($new_session = true)
|
function session_kill($new_session = true)
|
||||||
{
|
{
|
||||||
global $SID, $_SID, $db, $config, $phpbb_root_path, $phpEx;
|
global $SID, $_SID, $db, $config, $phpbb_root_path, $phpEx, $phpbb_container;
|
||||||
|
|
||||||
$sql = 'DELETE FROM ' . SESSIONS_TABLE . "
|
$sql = 'DELETE FROM ' . SESSIONS_TABLE . "
|
||||||
WHERE session_id = '" . $db->sql_escape($this->session_id) . "'
|
WHERE session_id = '" . $db->sql_escape($this->session_id) . "'
|
||||||
|
@ -895,12 +887,8 @@ class phpbb_session
|
||||||
// Allow connecting logout with external auth method logout
|
// Allow connecting logout with external auth method logout
|
||||||
$method = basename(trim($config['auth_method']));
|
$method = basename(trim($config['auth_method']));
|
||||||
|
|
||||||
$class = 'phpbb_auth_provider_' . $method;
|
$provider = $phpbb_container->get('auth.provider.' . $method);
|
||||||
if (class_exists($class))
|
|
||||||
{
|
|
||||||
$provider = new $class();
|
|
||||||
$provider->logout($this->data, $new_session);
|
$provider->logout($this->data, $new_session);
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->data['user_id'] != ANONYMOUS)
|
if ($this->data['user_id'] != ANONYMOUS)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue