forked from matrix/element-web
Hook up onFormSubmit to make registration (dummy only) work again.
This commit is contained in:
parent
b4c0625961
commit
5424567a66
|
@ -20,6 +20,7 @@ var React = require('react');
|
||||||
|
|
||||||
var sdk = require('matrix-react-sdk');
|
var sdk = require('matrix-react-sdk');
|
||||||
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
|
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
|
||||||
|
var dis = require('matrix-react-sdk/lib/dispatcher');
|
||||||
var ServerConfig = require("./ServerConfig");
|
var ServerConfig = require("./ServerConfig");
|
||||||
var RegistrationForm = require("./RegistrationForm");
|
var RegistrationForm = require("./RegistrationForm");
|
||||||
var MIN_PASSWORD_LENGTH = 6;
|
var MIN_PASSWORD_LENGTH = 6;
|
||||||
|
@ -44,7 +45,11 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillMount: function() {
|
componentWillMount: function() {
|
||||||
|
this.dispatcherRef = dis.register(this.onAction);
|
||||||
|
},
|
||||||
|
|
||||||
|
componentWillUnmount: function() {
|
||||||
|
dis.unregister(this.dispatcherRef);
|
||||||
},
|
},
|
||||||
|
|
||||||
onHsUrlChanged: function(newHsUrl) {
|
onHsUrlChanged: function(newHsUrl) {
|
||||||
|
@ -57,8 +62,38 @@ module.exports = React.createClass({
|
||||||
this.forceUpdate(); // registration state may have changed.
|
this.forceUpdate(); // registration state may have changed.
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onAction: function(payload) {
|
||||||
|
if (payload.action !== "registration_step_update") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.forceUpdate();
|
||||||
|
},
|
||||||
|
|
||||||
onFormSubmit: function(formVals) {
|
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) {
|
onFormValidationFailed: function(errCode) {
|
||||||
|
@ -99,12 +134,13 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
_getRegisterContentJsx: function() {
|
_getRegisterContentJsx: function() {
|
||||||
var currState = this.props.registerLogic.getState();
|
var currStep = this.props.registerLogic.getStep();
|
||||||
var registerStep;
|
var registerStep;
|
||||||
switch (currState) {
|
switch (currStep) {
|
||||||
case "Register.COMPLETE":
|
case "Register.COMPLETE":
|
||||||
return this._getPostRegisterJsx();
|
return this._getPostRegisterJsx();
|
||||||
case "Register.START":
|
case "Register.START":
|
||||||
|
case "Register.STEP_m.login.dummy":
|
||||||
registerStep = (
|
registerStep = (
|
||||||
<RegistrationForm
|
<RegistrationForm
|
||||||
showEmail={true}
|
showEmail={true}
|
||||||
|
@ -129,13 +165,14 @@ module.exports = React.createClass({
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.error("Unknown register state: %s", currState);
|
console.error("Unknown register state: %s", currStep);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h2>Create an account</h2>
|
<h2>Create an account</h2>
|
||||||
{registerStep}
|
{registerStep}
|
||||||
|
<div className="mx_Login_error">{this.state.errorText}</div>
|
||||||
<ServerConfig ref="serverConfig"
|
<ServerConfig ref="serverConfig"
|
||||||
withToggleButton={true}
|
withToggleButton={true}
|
||||||
defaultHsUrl={this.state.enteredHomeserverUrl}
|
defaultHsUrl={this.state.enteredHomeserverUrl}
|
||||||
|
@ -143,7 +180,6 @@ module.exports = React.createClass({
|
||||||
onHsUrlChanged={this.onHsUrlChanged}
|
onHsUrlChanged={this.onHsUrlChanged}
|
||||||
onIsUrlChanged={this.onIsUrlChanged}
|
onIsUrlChanged={this.onIsUrlChanged}
|
||||||
delayTimeMs={1000} />
|
delayTimeMs={1000} />
|
||||||
<div className="mx_Login_error">{this.state.errorText}</div>
|
|
||||||
<a className="mx_Login_create" onClick={this.props.onLoginClick} href="#">
|
<a className="mx_Login_create" onClick={this.props.onLoginClick} href="#">
|
||||||
I already have an account
|
I already have an account
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -175,7 +175,6 @@ module.exports = React.createClass({
|
||||||
registrationUrl={this.props.registrationUrl}
|
registrationUrl={this.props.registrationUrl}
|
||||||
/>
|
/>
|
||||||
); */
|
); */
|
||||||
return (
|
|
||||||
var registerLogic = new Signup.Register(
|
var registerLogic = new Signup.Register(
|
||||||
config.default_hs_url, config.default_is_url
|
config.default_hs_url, config.default_is_url
|
||||||
);
|
);
|
||||||
|
@ -183,6 +182,7 @@ module.exports = React.createClass({
|
||||||
registerLogic.setSessionId(this.state.register_session_id);
|
registerLogic.setSessionId(this.state.register_session_id);
|
||||||
registerLogic.setRegistrationUrl(this.props.registrationUrl);
|
registerLogic.setRegistrationUrl(this.props.registrationUrl);
|
||||||
registerLogic.setIdSid(this.state.register_id_sid);
|
registerLogic.setIdSid(this.state.register_id_sid);
|
||||||
|
return (
|
||||||
<Registration
|
<Registration
|
||||||
onLoggedIn={this.onLoggedIn}
|
onLoggedIn={this.onLoggedIn}
|
||||||
onLoginClick={this.onLoginClick}
|
onLoginClick={this.onLoginClick}
|
||||||
|
|
Loading…
Reference in New Issue