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)
|
||||
{
|
||||
$class = 'phpbb_auth_provider_' . $method;
|
||||
if (class_exists($class))
|
||||
$provider = $phpbb_container->get('auth.provider.' . $method);
|
||||
if ($provider)
|
||||
{
|
||||
$provider = new $class();
|
||||
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
|
||||
|
@ -586,10 +585,9 @@ class acp_board
|
|||
$method = basename($cfg_array['auth_method']);
|
||||
if ($method)
|
||||
{
|
||||
$class = 'phpbb_auth_provider_' . $method;
|
||||
if (class_exists($class))
|
||||
$provider = $phpbb_container->get('auth.provider.' . $method);
|
||||
if ($provider)
|
||||
{
|
||||
$provider = new $class();
|
||||
if ($error = $provider->init())
|
||||
{
|
||||
foreach ($old_auth_config as $config_name => $config_value)
|
||||
|
@ -685,10 +683,9 @@ class acp_board
|
|||
{
|
||||
if ($method)
|
||||
{
|
||||
$class = 'phpbb_auth_provider_' . $method;
|
||||
if (class_exists($class))
|
||||
$provider = $phpbb_container->get('auth.provider.' . $method);
|
||||
if ($provider)
|
||||
{
|
||||
$provider = new $class();
|
||||
$fields = $provider->acp($this->new_config);
|
||||
|
||||
if ($fields['tpl'])
|
||||
|
|
|
@ -927,14 +927,13 @@ class phpbb_auth
|
|||
*/
|
||||
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']));
|
||||
|
||||
$class = 'phpbb_auth_provider_' . $method;
|
||||
if (class_exists($class))
|
||||
$provider = $phpbb_container->get('auth.provider.' . $method);
|
||||
if ($provider)
|
||||
{
|
||||
$provider = new $class();
|
||||
$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
|
||||
|
|
|
@ -207,7 +207,7 @@ class phpbb_session
|
|||
function session_begin($update_session_page = true)
|
||||
{
|
||||
global $phpEx, $SID, $_SID, $_EXTRA_URL, $db, $config, $phpbb_root_path;
|
||||
global $request;
|
||||
global $request, $phpbb_container;
|
||||
|
||||
// Give us some basic information
|
||||
$this->time_now = time();
|
||||
|
@ -403,16 +403,12 @@ class phpbb_session
|
|||
// Check whether the session is still valid if we have one
|
||||
$method = basename(trim($config['auth_method']));
|
||||
|
||||
$class = 'phpbb_auth_provider_' . $method;
|
||||
if (class_exists($class))
|
||||
{
|
||||
$provider = new $class();
|
||||
$provider = $phpbb_container->get('auth.provider.' . $method);
|
||||
$ret = $provider->validate_session($this->data);
|
||||
if ($ret !== null && !$ret)
|
||||
{
|
||||
$session_expired = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$session_expired)
|
||||
{
|
||||
|
@ -505,7 +501,7 @@ class phpbb_session
|
|||
*/
|
||||
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();
|
||||
|
||||
|
@ -570,10 +566,7 @@ class phpbb_session
|
|||
|
||||
$method = basename(trim($config['auth_method']));
|
||||
|
||||
$class = 'phpbb_auth_provider_' . $method;
|
||||
if (class_exists($class))
|
||||
{
|
||||
$provider = new $class();
|
||||
$provider = $phpbb_container->get('auth.provider.' . $method);
|
||||
$this->data = $provider->autologin();
|
||||
|
||||
if (sizeof($this->data))
|
||||
|
@ -581,7 +574,6 @@ class phpbb_session
|
|||
$this->cookie_data['k'] = '';
|
||||
$this->cookie_data['u'] = $this->data['user_id'];
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
|
@ -885,7 +877,7 @@ class phpbb_session
|
|||
*/
|
||||
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 . "
|
||||
WHERE session_id = '" . $db->sql_escape($this->session_id) . "'
|
||||
|
@ -895,12 +887,8 @@ class phpbb_session
|
|||
// Allow connecting logout with external auth method logout
|
||||
$method = basename(trim($config['auth_method']));
|
||||
|
||||
$class = 'phpbb_auth_provider_' . $method;
|
||||
if (class_exists($class))
|
||||
{
|
||||
$provider = new $class();
|
||||
$provider = $phpbb_container->get('auth.provider.' . $method);
|
||||
$provider->logout($this->data, $new_session);
|
||||
}
|
||||
|
||||
if ($this->data['user_id'] != ANONYMOUS)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue