From 537104c56b1c3df1235738996dbbed7f0970a84a Mon Sep 17 00:00:00 2001 From: Matthew Taylor Date: Fri, 12 Aug 2016 08:10:20 -0400 Subject: [PATCH] Add username validation to student complete registration Fixes #760 --- src/components/forms/validations.jsx | 1 + src/components/registration/steps.jsx | 11 ++++++++--- .../studentcompleteregistration.jsx | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/components/forms/validations.jsx b/src/components/forms/validations.jsx index 6410322b9..bd5099e05 100644 --- a/src/components/forms/validations.jsx +++ b/src/components/forms/validations.jsx @@ -23,6 +23,7 @@ module.exports.validations = { return phoneNumberUtil.isValidNumber(parsed); } }; +module.exports.validations.notEqualsUsername = module.exports.validations.notEquals; module.exports.validationHOCFactory = function (defaultValidationErrors) { return function (Component) { diff --git a/src/components/registration/steps.jsx b/src/components/registration/steps.jsx index 4ec552334..dbf643afc 100644 --- a/src/components/registration/steps.jsx +++ b/src/components/registration/steps.jsx @@ -226,6 +226,7 @@ module.exports = { ChoosePasswordStep: intl.injectIntl(React.createClass({ getDefaultProps: function () { return { + studentUsername: null, showPassword: false, waiting: false }; @@ -257,7 +258,7 @@ module.exports = { validations={{ minLength: 6, notEquals: 'password', - notEqualsField: 'user.username' + notEqualsUsername: this.props.studentUsername }} validationErrors={{ minLength: formatMessage({ @@ -266,7 +267,7 @@ module.exports = { notEquals: formatMessage({ id: 'registration.validationPasswordNotEquals' }), - notEqualsField: formatMessage({ + notEqualsUsername: formatMessage({ id: 'registration.validationPasswordNotUsername' }) }} @@ -879,7 +880,11 @@ module.exports = { }; }, onNextStep: function () { - this.props.onNextStep(); + this.props.onNextStep({ + user: { + username: this.props.studentUsername + } + }); }, render: function () { var formatMessage = this.props.intl.formatMessage; diff --git a/src/views/studentcompleteregistration/studentcompleteregistration.jsx b/src/views/studentcompleteregistration/studentcompleteregistration.jsx index 50df16443..6b682c7ff 100644 --- a/src/views/studentcompleteregistration/studentcompleteregistration.jsx +++ b/src/views/studentcompleteregistration/studentcompleteregistration.jsx @@ -132,7 +132,11 @@ var StudentCompleteRegistration = intl.injectIntl(React.createClass({ {this.props.must_reset_password ? + waiting={this.state.waiting} + studentUsername={ + this.state.formData.user && + this.state.formData.user.username + } /> : [] }