diff --git a/src/MatrixClientPeg.js b/src/MatrixClientPeg.js index a1c820ee1..0b6c26496 100644 --- a/src/MatrixClientPeg.js +++ b/src/MatrixClientPeg.js @@ -24,11 +24,13 @@ var matrixClient = null; var localStorage = window.localStorage; if (localStorage) { var hs_url = localStorage.getItem("mx_hs_url"); + var is_url = localStorage.getItem("mx_is_url") || 'https://matrix.org'; var access_token = localStorage.getItem("mx_access_token"); var user_id = localStorage.getItem("mx_user_id"); if (access_token && user_id && hs_url) { matrixClient = Matrix.createClient({ baseUrl: hs_url, + idBaseUrl: is_url, accessToken: access_token, userId: user_id }); @@ -44,8 +46,11 @@ module.exports = { matrixClient = cli; }, - replaceUsingUrl: function(hs_url) { - matrixClient = Matrix.createClient(hs_url); + replaceUsingUrls: function(hs_url, is_url) { + matrixClient = Matrix.createClient({ + baseUrl: hs_url, + idBaseUrl: is_url + }); } }; diff --git a/src/controllers/molecules/ServerConfig.js b/src/controllers/molecules/ServerConfig.js index 3cd5156ba..76909a148 100644 --- a/src/controllers/molecules/ServerConfig.js +++ b/src/controllers/molecules/ServerConfig.js @@ -30,7 +30,7 @@ module.exports = { return { onHsUrlChanged: function() {}, onIsUrlChanged: function() {}, - default_hs_url: 'https://matrix.org/', + default_hs_url: 'http://localhost:8008', default_is_url: 'https://matrix.org/' }; }, diff --git a/src/controllers/templates/Login.js b/src/controllers/templates/Login.js index a5bd43ccf..48ff6dc9f 100644 --- a/src/controllers/templates/Login.js +++ b/src/controllers/templates/Login.js @@ -42,8 +42,14 @@ module.exports = { onHSChosen: function(ev) { ev.preventDefault(); - MatrixClientPeg.replaceUsingUrl(this.refs.serverConfig.getHsUrl()); - this.setState({hs_url: this.refs.serverConfig.getHsUrl()}); + MatrixClientPeg.replaceUsingUrls( + this.refs.serverConfig.getHsUrl(), + this.refs.serverConfig.getIsUrl() + ); + this.setState({ + hs_url: this.refs.serverConfig.getHsUrl(), + is_url: this.refs.serverConfig.getIsUrl() + }); this.setStep("fetch_stages"); var cli = MatrixClientPeg.get(); this.setState({busy: true}); @@ -72,12 +78,14 @@ module.exports = { // XXX: we assume this means we're logged in, but there could be a next stage MatrixClientPeg.replace(Matrix.createClient({ baseUrl: that.state.hs_url, + idBaseUrl: that.state.is_url, userId: data.user_id, accessToken: data.access_token })); var localStorage = window.localStorage; if (localStorage) { localStorage.setItem("mx_hs_url", that.state.hs_url); + localStorage.setItem("mx_is_url", that.state.is_url); localStorage.setItem("mx_user_id", data.user_id); localStorage.setItem("mx_access_token", data.access_token); } else { diff --git a/src/controllers/templates/Register.js b/src/controllers/templates/Register.js index 307a1dbe7..c562a79e7 100644 --- a/src/controllers/templates/Register.js +++ b/src/controllers/templates/Register.js @@ -87,7 +87,6 @@ module.exports = { if (this.savedParams.email != '') { return emailFlow; -t } else { return otherFlow; } @@ -95,8 +94,14 @@ t onInitialStageSubmit: function(ev) { ev.preventDefault(); - MatrixClientPeg.replaceUsingUrl(this.refs.serverConfig.getHsUrl()); - this.setState({hs_url: this.refs.serverConfig.getHsUrl()}); + MatrixClientPeg.replaceUsingUrls( + this.refs.serverConfig.getHsUrl(), + this.refs.serverConfig.getIsUrl() + ); + this.setState({ + hs_url: this.refs.serverConfig.getHsUrl(), + is_url: this.refs.serverConfig.getIsUrl() + }); var cli = MatrixClientPeg.get(); this.setState({busy: true}); var self = this; @@ -119,7 +124,7 @@ t busy: true }); var cli = MatrixClientPeg.get(); - this.savedParams.client_secret = cli.generarteClientSecret(); + this.savedParams.client_secret = cli.generateClientSecret(); this.savedParams.send_attempt = 1; cli.requestEmailToken( this.savedParams.email, @@ -150,6 +155,7 @@ t onRegistered: function(user_id, access_token) { MatrixClientPeg.replace(Matrix.createClient({ baseUrl: this.state.hs_url, + idBaseUrl: this.state.is_url, userId: user_id, accessToken: access_token }));