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.choosePasswordStepTitle": "Create a password",
"registration.choosePasswordStepTooltip": "Don't use your name or anything that's easy for someone else to guess.", "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.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.classroomInviteExistingStudentStepDescription": "you have been invited to join the class:",
"registration.classroomInviteNewStudentStepDescription": "has invited you to join the class:", "registration.classroomInviteNewStudentStepDescription": "has invited you to join the class:",
"registration.confirmYourEmail": "Confirm Your Email", "registration.confirmYourEmail": "Confirm Your Email",

View file

@ -86,11 +86,18 @@ var StudentCompleteRegistration = intl.injectIntl(React.createClass({
method: 'post', method: 'post',
useCsrf: true, useCsrf: true,
formData: submittedData formData: submittedData
}, function (err, body) { }, function (err, body, res) {
this.setState({waiting: false}); this.setState({waiting: false});
if (err) return this.setState({registrationError: err}); if (err) return this.setState({registrationError: err});
if (body.success) return this.advanceStep(formData); 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)); }.bind(this));
}, },
goToClass: function () { goToClass: function () {

View file

@ -78,11 +78,15 @@ var StudentRegistration = intl.injectIntl(React.createClass({
classroom_id: this.props.classroomId, classroom_id: this.props.classroomId,
classroom_token: this.props.classroomToken classroom_token: this.props.classroomToken
} }
}, function (err, res) { }, function (err, body, res) {
this.setState({waiting: false}); this.setState({waiting: false});
if (err) return this.setState({registrationError: err}); if (err) return this.setState({registrationError: err});
if (res[0].success) return this.advanceStep(formData); if (body[0].success) 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)); }.bind(this));
}, },
goToClass: function () { goToClass: function () {

View file

@ -66,14 +66,18 @@ var TeacherRegistration = React.createClass({
address_zip: this.state.formData.address.zip, address_zip: this.state.formData.address.zip,
how_use_scratch: this.state.formData.useScratch how_use_scratch: this.state.formData.useScratch
} }
}, function (err, res) { }, function (err, body, res) {
this.setState({waiting: false}); this.setState({waiting: false});
if (err) return this.setState({registrationError: err}); if (err) return this.setState({registrationError: err});
if (res[0].success) { if (body[0].success) {
this.props.dispatch(sessionActions.refreshSession()); this.props.dispatch(sessionActions.refreshSession());
return this.advanceStep(formData); 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)); }.bind(this));
}, },