Problem/Motivation

This is a really useful module, but it would be really beneficial if we were able to utilise drush to carry out this functionality. Currently, forcing user logouts requires accessing the admin UI, which isn't always convenient for site administrators who prefer CLI workflows or need to automate logout operations.

Proposed resolution

We propose abstracting the shared logout functionality into a shared service which would then be used by the existing form based functionality and a new drush command.

New service: UserLogoutService (src/UserLogoutService.php)

  • logoutUser($user) - Logout a single user
  • logoutUsers($users) - Logout multiple users
  • logoutByRoles($role_ids) - Logout users by role(s)
  • logoutAllExceptAdmin() - Logout all non-admin users
  • loadUserByName($username) - Load user by username
  • getAvailableRoles() - Get available custom roles

New Drush commands:

  • drush force-logout:user (alias: flu) - Logout a single user
  • drush force-logout:roles (alias: flr) - Logout users by role(s)
  • drush force-logout:roles --list - List available roles
  • drush force-logout:all (alias: fla) - Logout all non-admin users (with confirmation)

API changes

New service force_users_logout.user_logout available for dependency injection, allowing other modules to programmatically force user logouts.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

andy_w created an issue.