mattermost/mattermost-redux

Login does not save token

saitho opened this issue · 0 comments

Summary

Calling the "login" method does not set the token (anymore?).
The example in the readme suggests that it should:

client.setUrl('https://your-mattermost-url.com');
client.login(username, password)
.then(function(me){
    console.log(`logged in as ${me.email}`);
    token = client.getToken(); // empty!
})

Steps to reproduce

Execute the example code with valid server URL and credentials (username and password).

Expected behavior

I expect the token to be stored in the client.
If the login is done with a password, the token received from Mattermost server in response header should be saved.
If the login is done with a token, the used token should be saved.

Observed behavior

Subsequent API actions want me to authenticate again. I can't use the API using this library with username and password.

Possible fixes

I guess somewhere around https://github.com/mattermost/mattermost-redux/blob/master/src/client/client4.ts#L658, but I don't know where to get the response header.

My current workaround: Send a separate login via Axios to get the token.