About login out


#1

Good morning,

I was wondering if could exist the possibility (with some api or command) to log out a logged in user (I explain myself). I mean to log out all logged in sessions (at least the web logged ones) and that sessions would have been initiated by the user from, for instance, the https interface. Something like, ask for immediate disconection or session destroy…

Is that possible?.

Best regards,


#2

There are a couple ways to do this. First, we have an API call that can log a user out of all their active sessions. Also, you can use the platform command like this:

$ cd <your mattermost path>
$ sudo bin/platform user deactivate username1
$ sudo bin/platform user activate username1

Replace <your mattermost path> with the path to your Mattermost installation, and username1 with the username, user id, or email of the user you want to log out. If there are more users just separate their identifiers with spaces

You can find out more about the Mattermost command line tools here.


#3

Hi Paul!

Thanks a lot for your help. I was taking a look to the nice api you have… and have just seen (five minutes ago) :slight_smile: this way through the api. I assumed deactivate/activate (that’s why I asked about this), are not an option because I prettend just to logout web browser sessions when logging out from one site… for being a unified logout…

I would like to know by the way… if could be possible to know the web browser’ session id in order to just logout that session though the api… but not the cell sessions… for instance… Is that possible if I have not generated a users token for accesing?.

Thanks a lot really,
Best regards,


#4

I think I will perhaps end up by authenticating against Mattermost api, later getting a personal token (for the web browser avoiding expires…) and latter when desired to logout destroying that token through the api… I think it will be proper way…

I’m trying to figure now… how to later work with the token… I mean, I get the token because a proper login, later you work with it, chat and so (this is the part I don’t really know how to perform with that token) and finally destroy with the api that token…

I’m tryinng to investigate how to work with that token…

Cheers mate :slight_smile: