Logout any user from panel via Action-Button

I was wondering if it is possible to manually logout any user from within the panel, e.g. through a custom Options-Button in the accounts list.

Background: I have a project where many users work inside the panel, for security reasons I want to have the opportunity as admin to force a logout for a specific user. Is there a way to accomplish that? Because when I user $user->logout() im only logging my self out, event if I search the user by his id like $user = kirby()->user(any_id)

Users are automatically logged out if their session was created before the last password change. You don’t actually need to change the password though. You can “fake” this by running:

touch($user->root() . '/.htpasswd');

This updates the modification timestamp of the secrets file, which will trigger the same logic.

1 Like

Hey @lukasbestle ,
will this also trigger a hook in kirby?

touch() is a low level PHP function that won’t trigger any logic inside the Kirby core. You can manually trigger hooks with $kirby->trigger() though.

The automatic logout when the user returns to their (now stale) session triggers the user.logout hook.

Got it… that’s not really what i wanted but i will open a new topic about that i guess.

Thank you.