diff --git a/src/Lifecycle.js b/src/Lifecycle.js index 295ffe44f4..76b07bc6ed 100644 --- a/src/Lifecycle.js +++ b/src/Lifecycle.js @@ -304,6 +304,10 @@ export function setLoggedIn(credentials) { rtsClient.login(credentials.userId).then((body) => { if (body.team_token) { localStorage.setItem("mx_team_token", body.team_token); + dis.dispatch({ + action: 'set_team_token', + value: body.team_token, + }) } }, (err) =>{ console.error( diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index e885614ffe..c7943bb56c 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -518,6 +518,9 @@ module.exports = React.createClass({ case 'set_theme': this._onSetTheme(payload.value); break; + case 'set_team_token': + this._onSetTeamToken(payload.value); + break; case 'on_logged_in': this._onLoggedIn(); break; @@ -692,6 +695,16 @@ module.exports = React.createClass({ } }, + /** + * Called when the team token is acquired at registration or login. This + * should only happen if the configured RTS (see config.json teamServerURL) + * recognises the user as having an email address that matches a team. + */ + _onSetTeamToken: function(teamToken) { + this._teamToken = teamToken; + this._setPage(PageTypes.HomePage); + }, + /** * Called when a new logged in session has started */ @@ -1003,8 +1016,7 @@ module.exports = React.createClass({ }, onTeamMemberRegistered: function(teamToken) { - this._teamToken = teamToken; - this._setPage(PageTypes.HomePage); + this._onSetTeamToken(teamToken); }, onFinishPostRegistration: function() {