Handle registration errors.
This commit is contained in:
parent
df790c1b54
commit
7aa4d50560
|
@ -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() {
|
||||
|
@ -166,10 +168,18 @@ module.exports = {
|
|||
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;
|
||||
}
|
||||
this.onBadFields(badFields);
|
||||
|
||||
MatrixClientPeg.replaceUsingUrls(
|
||||
this.getHsUrl(),
|
||||
|
@ -308,15 +318,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 New Issue