mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-26 17:16:11 -05:00
Provide fallback error messages
In case the response does not supply `msg` or `errors`, provide a default. If `registrationError(s)` is empty, we do not show the error card, which causes "silent" failures.
This commit is contained in:
parent
3f1c9dcccb
commit
64ceb2ae56
4 changed files with 24 additions and 8 deletions
|
@ -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",
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -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));
|
||||
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue