How to check whether a user already logined?

I try to logout a user by calling an API “/admin/user/{user_id}/log_out”, but before that, I try to I need to check whether the user already login. Is there any API for this purpose?

1 Like

Using an API key with administrator privileges, you could fetch the user info (e.g. https://meta.discourse.org/u/david.json), and then check the user_auth_tokens array for a list of active sessions. If it is empty, then the user is not logged in anywhere.

7 Likes

Thank you so much. This help me a lot!

2 Likes