Logout or redirect all current logged in users with an action from admin - Laravel 10
Hi everyone,
I have a question on my mind and i don't know if it can be achieved.
I have a laravel admin dashboard, I want an action from the admin (clicking a button for example) to make all current users logout or redirect to certain page immediately.
Can you help me with this
If you want all user sessions to end, you need some control over the sessions. It's a bit tricky with file based sessions but trivial if you're using database sessions or tokens. You can delete or update rows based on user id.
Redirecting users immediately after a logout like this requires some logic on the front end. How would a client know they've been logged out? They'd need to poll the server and redirect if they're no longer authenticated, for example.
@JussiMannisto
That's not what I'm thinking about but thanks for your help anyway.
I was thinking of pushing notification from admin that will make all listeners users redirect using js
@JussiMannisto
That's the easy case, i am updating a field in the database that defines a user active/inactive and i am using that field in the middleware to allow just active users to login.
I solved the problem using laravel middleware and pusher.
When button is clicked all users required to logout are flagged inactive using users table column called active, and a pusher notification is sent to all currently opened pages to reload the page then they are logged out by the middleware, this flag is used by middleware to check if user is authorised or not.