From ffa249c3c5f080f5204b48f7f7f7729478f5b93b Mon Sep 17 00:00:00 2001 From: Matthew Taylor Date: Thu, 1 Sep 2016 14:59:02 -0400 Subject: [PATCH] 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 --- src/components/registration/steps.jsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/registration/steps.jsx b/src/components/registration/steps.jsx index 3df19db70..f8160079e 100644 --- a/src/components/registration/steps.jsx +++ b/src/components/registration/steps.jsx @@ -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 + '/'