mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-23 07:38:07 -05:00
in email step, use remote validation
This commit is contained in:
parent
020231bb02
commit
d6e5637dbe
1 changed files with 11 additions and 6 deletions
|
@ -4,9 +4,9 @@ const React = require('react');
|
|||
const PropTypes = require('prop-types');
|
||||
import {Formik} from 'formik';
|
||||
const {injectIntl, intlShape} = require('react-intl');
|
||||
const emailValidator = require('email-validator');
|
||||
const FormattedMessage = require('react-intl').FormattedMessage;
|
||||
|
||||
const validate = require('../../lib/validate');
|
||||
const JoinFlowStep = require('./join-flow-step.jsx');
|
||||
const FormikInput = require('../../components/formik-forms/formik-input.jsx');
|
||||
const FormikCheckbox = require('../../components/formik-forms/formik-checkbox.jsx');
|
||||
|
@ -75,11 +75,16 @@ class EmailStep extends React.Component {
|
|||
}
|
||||
validateEmail (email) {
|
||||
if (!email) return this.props.intl.formatMessage({id: 'general.required'});
|
||||
const isValidLocally = emailValidator.validate(email);
|
||||
if (isValidLocally) {
|
||||
return null; // TODO: validate email address remotely
|
||||
}
|
||||
return this.props.intl.formatMessage({id: 'registration.validationEmailInvalid'});
|
||||
const localResult = validate.validateEmailLocally(email);
|
||||
if (!localResult.valid) return this.props.intl.formatMessage({id: localResult.errMsgId});
|
||||
return validate.validateEmailRemotely(email).then(
|
||||
remoteResult => {
|
||||
if (remoteResult.valid === true) {
|
||||
return null;
|
||||
}
|
||||
return this.props.intl.formatMessage({id: remoteResult.errMsgId});
|
||||
}
|
||||
);
|
||||
}
|
||||
validateForm () {
|
||||
return {};
|
||||
|
|
Loading…
Reference in a new issue