Merge pull request #1110 from rschamp/bugfix/fallback-registration-error

Provide fallback error messages
This commit is contained in:
Ray Schamp 2016-12-13 15:08:42 -05:00 committed by GitHub
commit 2539c4cf63
4 changed files with 24 additions and 8 deletions

View file

@ -110,6 +110,7 @@
"registration.choosePasswordStepTitle": "Create a password",
"registration.choosePasswordStepTooltip": "Don't use your name or anything that's easy for someone else to guess.",
"registration.classroomApiGeneralError": "Sorry, we could not find the registration information for this class",
"registration.generalError": "Sorry, an unexpected error occurred.",
"registration.classroomInviteExistingStudentStepDescription": "you have been invited to join the class:",
"registration.classroomInviteNewStudentStepDescription": "has invited you to join the class:",
"registration.confirmYourEmail": "Confirm Your Email",

View file

@ -86,11 +86,18 @@ var StudentCompleteRegistration = intl.injectIntl(React.createClass({
method: 'post',
useCsrf: true,
formData: submittedData
}, function (err, body) {
}, function (err, body, res) {
this.setState({waiting: false});
if (err) return this.setState({registrationError: err});
if (body.success) return this.advanceStep(formData);
this.setState({registrationErrors: body.errors});
this.setState({
registrationErrors:
body.errors || {
__all__:
this.props.intl.formatMessage({id: 'registration.generalError'}) +
' (' + res.statusCode + ')'
}
});
}.bind(this));
},
goToClass: function () {

View file

@ -78,11 +78,15 @@ var StudentRegistration = intl.injectIntl(React.createClass({
classroom_id: this.props.classroomId,
classroom_token: this.props.classroomToken
}
}, function (err, res) {
}, function (err, body, res) {
this.setState({waiting: false});
if (err) return this.setState({registrationError: err});
if (res[0].success) return this.advanceStep(formData);
this.setState({registrationError: res[0].msg});
if (body[0].success) return this.advanceStep(formData);
this.setState({
registrationError:
body[0].msg ||
this.props.intl.formatMessage({id: 'registration.generalError'}) + ' (' + res.statusCode + ')'
});
}.bind(this));
},
goToClass: function () {

View file

@ -66,14 +66,18 @@ var TeacherRegistration = React.createClass({
address_zip: this.state.formData.address.zip,
how_use_scratch: this.state.formData.useScratch
}
}, function (err, res) {
}, function (err, body, res) {
this.setState({waiting: false});
if (err) return this.setState({registrationError: err});
if (res[0].success) {
if (body[0].success) {
this.props.dispatch(sessionActions.refreshSession());
return this.advanceStep(formData);
}
this.setState({registrationError: res[0].msg});
this.setState({
registrationError:
body[0].msg ||
this.props.intl.formatMessage({id: 'registration.generalError'}) + ' (' + res.statusCode + ')'
});
}.bind(this));
},