[SOLVED] Auto login? Site integration?

Hello everyone,

I have a forum and I did like to arrange something that logged in users when clicking a chat button will be auto logged and directed to a public channel.

Is there currently any way to achieve this? My installation of mattermost is mainly private so only registered users should have access to it(and only admins can create teams, etc) and I would like to avoid having users to create yet a new account on mattermost for that purpose.

I was also thinking of using the API to register all my current users and add it to the registration step to automatically register new users, but still I did like to exclude the double login step to access the chat.

What option do I have here, if any?

Excuse me if I posted in the wrong place, and thanks in advance…

Figured out you can re-set the cookies and redirect for that purpose.

Hi @prixone,

Thanks for your question! Seems you’ve solved your own issue :slight_smile:

Anything else we can help with or can this issue be closed off?

Yes, it can be closed, I’ve used a mix of PHP + api calls to make it happen while experimenting and it worked as expected.

Thanks for this amazing project.

Can technical details exactly how did you do it?

Можно технических подробностей как именно ты это сделал?

login with the API and pass the cookies to the client+redirect it.

Thanks @prixone!

Glad you’re up and running!

Thanks for your interest in Mattermost :slight_smile:

Can you please provide more detail please. Which api you used for login as I have see one for create user; however, couldn’t see the one for login. I am working with Django 2.1 and python 3.6. I am a novice developer. I am using Mattermost 5.2.1 and databse schema version 5.2.0 with Postgres 9.6 .

Thank you in advance

Hi @thinktwice,

There are two cookies that need to be set to login without a password and username. Here’s an example of how to set them:

setcookie('MMUSERID', '<user id from database>', time()+606024*30, ‘/’, ‘.yourdomain.com’, true, true);
setcookie('MMAUTHTOKEN', '<Authentication Token Value>', time()+606024*30, ‘/’, ‘.yourdomain.com’, true, true);

Replace <user id from database> and <Authentication Token Value> with their respective values for that user. You can get both of these values with a database query, or by using the authentication instructions for the Mattermost API..

Hope this helps,

4 Likes