Get team_token from the RTS on login
Use the /login endpoint of the RTS to get the team token when the user has successfully logged in.pull/21833/head
parent
68f644c824
commit
173e80a5de
|
@ -228,6 +228,11 @@ function _restoreFromLocalStorage() {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
const RtsClient = require("./RtsClient");
|
||||
let rtsClient = null;
|
||||
export function initRtsClient(url) {
|
||||
rtsClient = new RtsClient(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transitions to a logged-in state using the given credentials
|
||||
|
@ -261,6 +266,17 @@ export function setLoggedIn(credentials) {
|
|||
} catch (e) {
|
||||
console.warn("Error using local storage: can't persist session!", e);
|
||||
}
|
||||
|
||||
if (rtsClient) {
|
||||
rtsClient.login(credentials.userId).then((teamToken) => {
|
||||
localStorage.setItem("mx_team_token", teamToken);
|
||||
}, (err) =>{
|
||||
console.error(
|
||||
"Failed to get team token on login, not persisting to localStorage",
|
||||
err
|
||||
);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.warn("No local storage available: can't persist session!");
|
||||
}
|
||||
|
|
|
@ -77,4 +77,14 @@ export default class RtsClient {
|
|||
}
|
||||
);
|
||||
}
|
||||
|
||||
login(userId) {
|
||||
return request(this._url + '/login',
|
||||
{
|
||||
qs: {
|
||||
user_id: userId,
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,6 +210,8 @@ module.exports = React.createClass({
|
|||
window.addEventListener('resize', this.handleResize);
|
||||
this.handleResize();
|
||||
|
||||
Lifecycle.initRtsClient(this.props.config.teamServerConfig.teamServerURL);
|
||||
|
||||
// the extra q() ensures that synchronous exceptions hit the same codepath as
|
||||
// asynchronous ones.
|
||||
q().then(() => {
|
||||
|
|
Loading…
Reference in New Issue