Merge branch 'master' into vector
This commit is contained in:
commit
cf38b8a5bb
2 changed files with 46 additions and 15 deletions
|
@ -53,10 +53,10 @@ module.exports = React.createClass({
|
|||
return (
|
||||
<div>
|
||||
<form onSubmit={this.onInitialStageSubmit}>
|
||||
Email: <input type="text" ref="email" /><br />
|
||||
Username: <input type="text" ref="username" /><br />
|
||||
Password: <input type="password" ref="password" /><br />
|
||||
Confirm Password: <input type="password" ref="confirmPassword" /><br />
|
||||
Email: <input type="text" ref="email" defaultValue={this.savedParams.email} /><br />
|
||||
Username: <input type="text" ref="username" defaultValue={this.savedParams.username} /><br />
|
||||
Password: <input type="password" ref="password" defaultValue={this.savedParams.password} /><br />
|
||||
Confirm Password: <input type="password" ref="confirmPassword" defaultValue={this.savedParams.confirmPassword} /><br />
|
||||
<ServerConfig ref="serverConfig" />
|
||||
<input type="submit" value="Continue" />
|
||||
</form>
|
||||
|
@ -104,6 +104,15 @@ module.exports = React.createClass({
|
|||
case this.FieldErrors.PasswordMismatch:
|
||||
strings.push("Passwords don't match");
|
||||
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(', ');
|
||||
|
|
|
@ -27,7 +27,9 @@ var ComponentBroker = require("../../ComponentBroker");
|
|||
module.exports = {
|
||||
FieldErrors: {
|
||||
PasswordMismatch: 'PasswordMismatch',
|
||||
PasswordLength: 'PasswordLength'
|
||||
TooShort: 'TooShort',
|
||||
Missing: 'Missing',
|
||||
InUse: 'InUse'
|
||||
},
|
||||
|
||||
getInitialState: function() {
|
||||
|
@ -40,6 +42,12 @@ module.exports = {
|
|||
},
|
||||
|
||||
componentWillMount: function() {
|
||||
this.savedParams = {
|
||||
email: '',
|
||||
username: '',
|
||||
password: '',
|
||||
confirmPassword: ''
|
||||
};
|
||||
this.readNewProps();
|
||||
},
|
||||
|
||||
|
@ -161,15 +169,24 @@ module.exports = {
|
|||
ev.preventDefault();
|
||||
|
||||
var formVals = this.getRegFormVals();
|
||||
this.savedParams = formVals;
|
||||
|
||||
var badFields = {};
|
||||
if (formVals.password != formVals.confirmPassword) {
|
||||
badFields.confirmPassword = this.FieldErrors.PasswordMismatch;
|
||||
}
|
||||
if (formVals.password.length < 6) {
|
||||
badFields.password = this.FieldErrors.PasswordLength;
|
||||
if (formVals.password == '') {
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
MatrixClientPeg.replaceUsingUrls(
|
||||
this.getHsUrl(),
|
||||
|
@ -308,15 +325,20 @@ module.exports = {
|
|||
});
|
||||
self.startStage(flow.stages[flowStage]);
|
||||
} else {
|
||||
var errorText = "Unable to contact the given Home Server";
|
||||
if (error.httpStatus == 401) {
|
||||
errorText = "Authorisation failed!";
|
||||
}
|
||||
self.setStep("initial");
|
||||
self.setState({
|
||||
var newState = {
|
||||
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 a new issue