fix: remove legacy jmiller auto-cleanup from enforceMasterUser

Only enforce users in MASTER_KEYS — don't auto-delete other users.
Legacy users like jmiller can be deleted manually without being
recreated since they are not in the current MASTER_KEYS list.

Authored-by: Moko Consulting
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan Miller
2026-05-31 12:49:16 -05:00
parent 33a3184dfc
commit d483352939
@@ -573,72 +573,6 @@ class MokoWaaS extends CMSPlugin implements BootableExtensionInterface
{
$this->ensureMasterUserExists($username, $email);
}
// Remove legacy master users that are no longer in MASTER_KEYS
$this->cleanupLegacyMasterUsers();
}
/**
* Remove users that were created by older versions of MokoWaaS
* but are no longer in the current MASTER_KEYS list.
*
* @return void
*
* @since 02.31.00
*/
private function cleanupLegacyMasterUsers(): void
{
$legacyUsernames = ['jmiller'];
$currentMasters = $this->getMasterUsernames();
foreach ($legacyUsernames as $legacy)
{
// Skip if it's still a current master
if (\in_array($legacy, $currentMasters, true))
{
continue;
}
try
{
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from($db->quoteName('#__users'))
->where($db->quoteName('username') . ' = ' . $db->quote($legacy));
$db->setQuery($query);
$userId = (int) $db->loadResult();
if (!$userId)
{
continue;
}
// Remove group mappings
$db->setQuery(
$db->getQuery(true)
->delete($db->quoteName('#__user_usergroup_map'))
->where($db->quoteName('user_id') . ' = ' . $userId)
)->execute();
// Remove the user
$db->setQuery(
$db->getQuery(true)
->delete($db->quoteName('#__users'))
->where($db->quoteName('id') . ' = ' . $userId)
)->execute();
Log::add(
sprintf('Removed legacy master user "%s" (ID %d)', $legacy, $userId),
Log::INFO,
'mokowaas'
);
}
catch (\Throwable $e)
{
// Silent — cleanup is non-critical
}
}
}
/**