diff --git a/src/components/login/Registration.js b/src/components/login/Registration.js index c44d136855..05960c610a 100644 --- a/src/components/login/Registration.js +++ b/src/components/login/Registration.js @@ -20,6 +20,7 @@ var React = require('react'); var sdk = require('matrix-react-sdk'); var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg'); +var dis = require('matrix-react-sdk/lib/dispatcher'); var ServerConfig = require("./ServerConfig"); var RegistrationForm = require("./RegistrationForm"); var MIN_PASSWORD_LENGTH = 6; @@ -44,7 +45,11 @@ module.exports = React.createClass({ }, componentWillMount: function() { + this.dispatcherRef = dis.register(this.onAction); + }, + componentWillUnmount: function() { + dis.unregister(this.dispatcherRef); }, onHsUrlChanged: function(newHsUrl) { @@ -57,8 +62,38 @@ module.exports = React.createClass({ this.forceUpdate(); // registration state may have changed. }, + onAction: function(payload) { + if (payload.action !== "registration_step_update") { + return; + } + this.forceUpdate(); + }, + onFormSubmit: function(formVals) { - console.log("Form vals: %s", formVals); + var self = this; + this.props.registerLogic.register(formVals).done(function(response) { + if (!response || !response.access_token) { + console.warn( + "FIXME: Register fulfilled without a final response, " + + "did you break the promise chain?" + ); + // no matter, we'll grab it direct + response = self.props.registerLogic.getCredentials(); + } + self.props.onLoggedIn({ + userId: response.user_id, + homeserverUrl: self.props.registerLogic.getHomeserverUrl(), + identityServerUrl: self.props.registerLogic.getIdentityServerUrl(), + accessToken: response.access_token + }); + }, function(err) { + if (err.message) { + self.setState({ + errorText: err.message + }); + } + console.log(err); + }); }, onFormValidationFailed: function(errCode) { @@ -99,12 +134,13 @@ module.exports = React.createClass({ }, _getRegisterContentJsx: function() { - var currState = this.props.registerLogic.getState(); + var currStep = this.props.registerLogic.getStep(); var registerStep; - switch (currState) { + switch (currStep) { case "Register.COMPLETE": return this._getPostRegisterJsx(); case "Register.START": + case "Register.STEP_m.login.dummy": registerStep = (

Create an account

{registerStep} +
{this.state.errorText}
-
{this.state.errorText}
I already have an account diff --git a/src/skins/vector/views/pages/MatrixChat.js b/src/skins/vector/views/pages/MatrixChat.js index 85506c213f..7dafff91ff 100644 --- a/src/skins/vector/views/pages/MatrixChat.js +++ b/src/skins/vector/views/pages/MatrixChat.js @@ -175,14 +175,14 @@ module.exports = React.createClass({ registrationUrl={this.props.registrationUrl} /> ); */ - return ( - var registerLogic = new Signup.Register( + var registerLogic = new Signup.Register( config.default_hs_url, config.default_is_url ); - registerLogic.setClientSecret(this.state.register_client_secret); - registerLogic.setSessionId(this.state.register_session_id); - registerLogic.setRegistrationUrl(this.props.registrationUrl); - registerLogic.setIdSid(this.state.register_id_sid); + registerLogic.setClientSecret(this.state.register_client_secret); + registerLogic.setSessionId(this.state.register_session_id); + registerLogic.setRegistrationUrl(this.props.registrationUrl); + registerLogic.setIdSid(this.state.register_id_sid); + return (