Merge branch 'master' into vector
This commit is contained in:
commit
cf38b8a5bb
|
@ -53,10 +53,10 @@ module.exports = React.createClass({
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<form onSubmit={this.onInitialStageSubmit}>
|
<form onSubmit={this.onInitialStageSubmit}>
|
||||||
Email: <input type="text" ref="email" /><br />
|
Email: <input type="text" ref="email" defaultValue={this.savedParams.email} /><br />
|
||||||
Username: <input type="text" ref="username" /><br />
|
Username: <input type="text" ref="username" defaultValue={this.savedParams.username} /><br />
|
||||||
Password: <input type="password" ref="password" /><br />
|
Password: <input type="password" ref="password" defaultValue={this.savedParams.password} /><br />
|
||||||
Confirm Password: <input type="password" ref="confirmPassword" /><br />
|
Confirm Password: <input type="password" ref="confirmPassword" defaultValue={this.savedParams.confirmPassword} /><br />
|
||||||
<ServerConfig ref="serverConfig" />
|
<ServerConfig ref="serverConfig" />
|
||||||
<input type="submit" value="Continue" />
|
<input type="submit" value="Continue" />
|
||||||
</form>
|
</form>
|
||||||
|
@ -104,6 +104,15 @@ module.exports = React.createClass({
|
||||||
case this.FieldErrors.PasswordMismatch:
|
case this.FieldErrors.PasswordMismatch:
|
||||||
strings.push("Passwords don't match");
|
strings.push("Passwords don't match");
|
||||||
break;
|
break;
|
||||||
|
case this.FieldErrors.Missing:
|
||||||
|
strings.push("Missing "+keys[i]);
|
||||||
|
break;
|
||||||
|
case this.FieldErrors.TooShort:
|
||||||
|
strings.push(keys[i]+" is too short");
|
||||||
|
break;
|
||||||
|
case this.FieldErrors.InUse:
|
||||||
|
strings.push(keys[i]+" is already taken");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var errtxt = strings.join(', ');
|
var errtxt = strings.join(', ');
|
||||||
|
|
|
@ -27,7 +27,9 @@ var ComponentBroker = require("../../ComponentBroker");
|
||||||
module.exports = {
|
module.exports = {
|
||||||
FieldErrors: {
|
FieldErrors: {
|
||||||
PasswordMismatch: 'PasswordMismatch',
|
PasswordMismatch: 'PasswordMismatch',
|
||||||
PasswordLength: 'PasswordLength'
|
TooShort: 'TooShort',
|
||||||
|
Missing: 'Missing',
|
||||||
|
InUse: 'InUse'
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
|
@ -40,6 +42,12 @@ module.exports = {
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillMount: function() {
|
componentWillMount: function() {
|
||||||
|
this.savedParams = {
|
||||||
|
email: '',
|
||||||
|
username: '',
|
||||||
|
password: '',
|
||||||
|
confirmPassword: ''
|
||||||
|
};
|
||||||
this.readNewProps();
|
this.readNewProps();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -161,15 +169,24 @@ module.exports = {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
|
|
||||||
var formVals = this.getRegFormVals();
|
var formVals = this.getRegFormVals();
|
||||||
|
this.savedParams = formVals;
|
||||||
|
|
||||||
var badFields = {};
|
var badFields = {};
|
||||||
if (formVals.password != formVals.confirmPassword) {
|
if (formVals.password != formVals.confirmPassword) {
|
||||||
badFields.confirmPassword = this.FieldErrors.PasswordMismatch;
|
badFields.confirmPassword = this.FieldErrors.PasswordMismatch;
|
||||||
}
|
}
|
||||||
if (formVals.password.length < 6) {
|
if (formVals.password == '') {
|
||||||
badFields.password = this.FieldErrors.PasswordLength;
|
badFields.password = this.FieldErrors.Missing;
|
||||||
|
} else if (formVals.password.length < 6) {
|
||||||
|
badFields.password = this.FieldErrors.Length;
|
||||||
}
|
}
|
||||||
|
if (formVals.username == '') {
|
||||||
|
badFields.username = this.FieldErrors.Missing;
|
||||||
|
}
|
||||||
|
if (Object.keys(badFields).length > 0) {
|
||||||
this.onBadFields(badFields);
|
this.onBadFields(badFields);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
MatrixClientPeg.replaceUsingUrls(
|
MatrixClientPeg.replaceUsingUrls(
|
||||||
this.getHsUrl(),
|
this.getHsUrl(),
|
||||||
|
@ -308,15 +325,20 @@ module.exports = {
|
||||||
});
|
});
|
||||||
self.startStage(flow.stages[flowStage]);
|
self.startStage(flow.stages[flowStage]);
|
||||||
} else {
|
} else {
|
||||||
var errorText = "Unable to contact the given Home Server";
|
|
||||||
if (error.httpStatus == 401) {
|
|
||||||
errorText = "Authorisation failed!";
|
|
||||||
}
|
|
||||||
self.setStep("initial");
|
self.setStep("initial");
|
||||||
self.setState({
|
var newState = {
|
||||||
busy: false,
|
busy: false,
|
||||||
errorText: errorText
|
errorText: "Unable to contact the given Home Server"
|
||||||
|
};
|
||||||
|
if (error.name == 'M_USER_IN_USE') {
|
||||||
|
delete newState.errorText;
|
||||||
|
self.onBadFields({
|
||||||
|
username: self.FieldErrors.InUse
|
||||||
});
|
});
|
||||||
|
} else if (error.httpStatus == 401) {
|
||||||
|
newState.errorText = "Authorisation failed!";
|
||||||
|
}
|
||||||
|
self.setState(newState);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue