removed commented out code from join flow steps

This commit is contained in:
Ben Wheeler 2019-07-02 17:37:56 -04:00
parent f6d1ba3194
commit 585340d289

View file

@ -31,57 +31,6 @@ class UsernameStep extends React.Component {
handleChangeShowPassword () { handleChangeShowPassword () {
this.setState({showPassword: !this.state.showPassword}); this.setState({showPassword: !this.state.showPassword});
} }
// validateUsernameLocally (username, require) {
// let error;
// if (username.length === 0 && !require) { // allow blank username if not submitting yet
// return null;
// }
// if (!username || username === '') {
// error = this.props.intl.formatMessage({id: 'form.validationRequiredNice'});
// } else if (username.length < 3) {
// error = this.props.intl.formatMessage({id: 'registration.validationUsernameMinLength'});
// } else if (username.length > 20) {
// error = this.props.intl.formatMessage({id: 'registration.validationUsernameMaxLength'});
// } else if (!/^[\w-]+$/i.test(username)) {
// error = this.props.intl.formatMessage({id: 'registration.validationUsernameRegexp'});
// }
// return error;
// }
// validateUsernameRemotely (username, require) {
// if (username.length === 0 && !require) { // allow blank username if not submitting yet
// return null;
// }
// return new Promise((resolve, reject) => {
// api({
// uri: `/accounts/checkusername/${username}/`
// }, (err, body, res) => {
// if (err || res.statusCode !== 200) {
// reject('api error');
// }
// switch (body.msg) {
// case 'valid username':
// resolve(null);
// break;
// case 'username exists':
// reject(this.props.intl.formatMessage({
// id: 'registration.validationUsernameExists'
// }));
// break;
// case 'bad username':
// reject(this.props.intl.formatMessage({
// id: 'registration.validationUsernameVulgar'
// }));
// break;
// case 'invalid username':
// default:
// reject(this.props.intl.formatMessage({
// id: 'registration.validationUsernameInvalid'
// }));
// }
// });
// });
// }
// we allow username to be empty on blur, since you might not have typed anything yet // we allow username to be empty on blur, since you might not have typed anything yet
validateUsernameIfPresent (username) { validateUsernameIfPresent (username) {
if (!username) return null; // skip validation if username is blank; null indicates valid if (!username) return null; // skip validation if username is blank; null indicates valid
@ -96,59 +45,12 @@ class UsernameStep extends React.Component {
} }
return this.props.intl.formatMessage({id: localResult.errMsgId}); return this.props.intl.formatMessage({id: localResult.errMsgId});
} }
// validateUsernameAdditionallyOnSubmit (username) {
// const localResult = validate.validateUsernameLocally(username);
// if (localResult.valid) return null
// return new Promise((resolve, reject) => {
// reject(this.props.intl.formatMessage({id: localResult.errMsgId}));
// });
// }
// validateUsername (username, require) {
// if (!require && !username) {
// return new Promise(resolve => { resolve(null); });
// }
// const localResult = validate.validateUsernameLocally(username);
// // if error, return that
// if (!localResult.valid && (require || !username)) {
// return new Promise((resolve, reject) => {
// reject(localResult);
// });
// }
// return this.validateUsernameRemotely(username, require);
// }
validatePasswordIfPresent (password) { validatePasswordIfPresent (password) {
if (!password) return null; // skip validation if password is blank; null indicates valid if (!password) return null; // skip validation if password is blank; null indicates valid
const localResult = validate.validatePassword(password); const localResult = validate.validatePassword(password);
if (localResult.valid) return null; if (localResult.valid) return null;
return this.props.intl.formatMessage({id: localResult.errMsgId}); return this.props.intl.formatMessage({id: localResult.errMsgId});
} }
// validatePassword (password, require) {
// let error;
// if (password.length === 0) {
// if (require) {
// return this.props.intl.formatMessage({id: 'form.validationRequired'});
// }
// // not submitting yet, so allow blank password, and don't throw error
// return null;
// }
// if (password.length < 6) {
// error = this.props.intl.formatMessage({id: 'registration.validationPasswordLength'});
// }
// if (password === 'password') {
// error = this.props.intl.formatMessage({id: 'registration.validationPasswordNotEquals'});
// }
// return error;
// }
// validatePassword (password, require) {
// return new Promise((resolve, reject) => {
// const localResult = this.validatePassword(password, require);
// if (localResult) {
// reject(localResult);
// } else {
// resolve(null);
// }
// });
// }
validatePasswordConfirmIfPresent (password, passwordConfirm) { validatePasswordConfirmIfPresent (password, passwordConfirm) {
if (!passwordConfirm) return null; // allow blank password if not submitting yet if (!passwordConfirm) return null; // allow blank password if not submitting yet
const localResult = validate.validatePasswordConfirm(password, passwordConfirm); const localResult = validate.validatePasswordConfirm(password, passwordConfirm);