diff --git a/resources/RemoveInactiveUsersRunner.php b/resources/RemoveInactiveUsersRunner.php index 7b4aa313e..4f3ba2cbb 100644 --- a/resources/RemoveInactiveUsersRunner.php +++ b/resources/RemoveInactiveUsersRunner.php @@ -47,6 +47,13 @@ $lastLoginDate = $user->getLastLoginDate(); + if (!$user->getAPIAuthenticationEntities()->isEmpty()) { + // Prevent creating orphaned API credentials. + echo "Cannot delete a user with attached API credentials.\n"; + // Move onto the next users. + continue; + } + if ($lastLoginDate) { // null lastLoginDate check $interval = $today->diff($lastLoginDate); } else { // This might only be run once, since new users always have field filled.