Check for username before sending

the `//` for an empty username that gets sent to the backend causes a 500 error. This is an edge case in formsy, as it has not detected a change value yet, so handle it in the username validation method. Fixes #872
This commit is contained in:
Matthew Taylor 2016-09-01 14:59:02 -04:00
parent 07d7750b9c
commit ffa249c3c5

View file

@ -91,6 +91,13 @@ module.exports = {
},
validateUsername: function (username, callback) {
callback = callback || function () {};
if (username.length < 1) {
this.refs.form.refs.formsy.updateInputsWithError({
'user.username': formatMessage({id: 'teacherRegistration.validationRequired'})
});
return callback(false);
}
api({
host: '',
uri: '/accounts/check_username/' + username + '/'