mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-25 19:11:47 +02:00
[ticket/13564] Try to unlink user account for every auth provider
PHPBB3-13564
This commit is contained in:
@@ -500,6 +500,9 @@ function user_delete($mode, $user_ids, $retain_username = true)
|
|||||||
|
|
||||||
$num_users_delta = 0;
|
$num_users_delta = 0;
|
||||||
|
|
||||||
|
// Get auth provider collection in case accounts might need to be unlinked
|
||||||
|
$provider_collection = $phpbb_container->get('auth.provider_collection');
|
||||||
|
|
||||||
// Some things need to be done in the loop (if the query changes based
|
// Some things need to be done in the loop (if the query changes based
|
||||||
// on which user is currently being deleted)
|
// on which user is currently being deleted)
|
||||||
$added_guest_posts = 0;
|
$added_guest_posts = 0;
|
||||||
@@ -510,6 +513,38 @@ function user_delete($mode, $user_ids, $retain_username = true)
|
|||||||
avatar_delete('user', $user_row);
|
avatar_delete('user', $user_row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unlink accounts
|
||||||
|
foreach ($provider_collection as $provider_name => $auth_provider)
|
||||||
|
{
|
||||||
|
$provider_data = $auth_provider->get_auth_link_data($user_id);
|
||||||
|
|
||||||
|
if ($provider_data !== null)
|
||||||
|
{
|
||||||
|
$link_data = array(
|
||||||
|
'user_id' => $user_id,
|
||||||
|
'link_method' => 'user_delete',
|
||||||
|
);
|
||||||
|
|
||||||
|
// BLOCK_VARS might contain hidden fields necessary for unlinking accounts
|
||||||
|
if (isset($provider_data['BLOCK_VARS']) && is_array($provider_data['BLOCK_VARS']))
|
||||||
|
{
|
||||||
|
foreach ($provider_data['BLOCK_VARS'] as $provider_service)
|
||||||
|
{
|
||||||
|
if (!array_key_exists('HIDDEN_FIELDS', $provider_service))
|
||||||
|
{
|
||||||
|
$provider_service['HIDDEN_FIELDS'] = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$auth_provider->unlink_account(array_merge($link_data, $provider_service['HIDDEN_FIELDS']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$auth_provider->unlink_account($link_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Decrement number of users if this user is active
|
// Decrement number of users if this user is active
|
||||||
if ($user_row['user_type'] != USER_INACTIVE && $user_row['user_type'] != USER_IGNORE)
|
if ($user_row['user_type'] != USER_INACTIVE && $user_row['user_type'] != USER_IGNORE)
|
||||||
{
|
{
|
||||||
|
@@ -38,6 +38,16 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case
|
|||||||
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
|
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
|
||||||
$phpbb_container = new phpbb_mock_container_builder();
|
$phpbb_container = new phpbb_mock_container_builder();
|
||||||
$phpbb_container->set('notification_manager', new phpbb_mock_notification_manager());
|
$phpbb_container->set('notification_manager', new phpbb_mock_notification_manager());
|
||||||
|
$phpbb_container->set(
|
||||||
|
'auth.provider.db',
|
||||||
|
new phpbb_mock_auth_provider()
|
||||||
|
);
|
||||||
|
$provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config);
|
||||||
|
$provider_collection->add('auth.provider.db');
|
||||||
|
$phpbb_container->set(
|
||||||
|
'auth.provider_collection',
|
||||||
|
$provider_collection
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function first_last_post_data()
|
public function first_last_post_data()
|
||||||
|
Reference in New Issue
Block a user