Exemple #1
0
 const handleSubmitClient = () => {
     if (name &&
         isEmail(email) &&
         ((accountType === 'group admin' && userLimit || accountType === 'individual lecturer') || (isEditingClient && userLimit))) {
         submitClient({ name, email, institution, department, accountType, paid, userLimit, isEditingClient });
     } else if (!name) {
         displayError({ message: 'Please enter a name for the client before saving' });
     } else if (!email || !isEmail(email)) {
         displayError({ message: 'Please enter an email for the client before saving' });
     } else if (!isEditingClient && !accountType ) {
         displayError({ message: 'Please select an account type for the client before saving' });
     } else if (accountType === 'group admin' && !userLimit) {
         displayError({ message: 'Please provide a user limit before saving' });
     }
 };
 getEmailValidationState() {
   const { emailValue } = this.state;
   if (maybeEmailRE.test(emailValue)) {
     return isEmail(emailValue) ? 'success' : 'error';
   }
   return null;
 }
Exemple #3
0
export async function passwordReset (ctx) {
  const { User, EmailCode } = ctx.orm();
  const { email } = ctx.request.body;

  if (!email || !isEmail(email)) {
    ctx.flash('error', 'Email is empty or invalid type');
    ctx.redirect(ctx._routes.password_reset);
    return;
  }

  const user = await User.findByEmail(email);
  if (!user) {
    ctx.flash('error', 'User not found');
    ctx.redirect(ctx._routes.password_reset);
    return;
  }

  try {
    const code = await EmailCode.create({
      user_id: user.id
    });
    await ctx.sendMail(user.email, 'password_reset', {
      username: user.email,
      ttl: ctx.config.emailCodeTTL / 3600,
      link: ctx.config.domain + ctx._routes.password_change + '?code=' + code.id
    });
    ctx.flash('success', 'Check your email for a link to reset your password.');
    ctx.redirect(ctx._routes.login);
  } catch (e) {
    console.error(e.stack);
    ctx.flash('error', 'Send email failed');
    ctx.redirect(ctx._routes.password_reset);
  }
}
Exemple #4
0
 handleSubmit() {
   const { email } = this.state;
   if (!email || !isEmail(email)) {
     return this.setState(state => ({
       ...state,
       donationState: {
         ...state.donationState,
         error:
           'We need a valid email address to send your donation tax reciept to'
       }
     }));
   }
   return this.props.stripe.createToken({ email }).then(({ error, token }) => {
     if (error) {
       return this.setState(state => ({
         ...state,
         donationState: {
           ...state.donationState,
           error:
             'Something went wrong processing your donation. Your card' +
             ' has not been charged.'
         }
       }));
     }
     return this.postDonation(token);
   });
 }
Exemple #5
0
export const validate = (values) => {
  const errors = {}
  const minPasswordLength = 5

  // Retrieve values
  let { email = '', password = '', passwordConfirmation = '' } = values

  // Check validity
  if (!email.trim()) {
    errors.email = 'Please type an email'
  }
  if (!isEmail(email)) {
    errors.email = 'Please type a valid email'
  }
  if (!password.trim()) {
    errors.password = 'Please type a password'
  }
  if (!isLength(password, { min : minPasswordLength })) {
    errors.password = `Password should be at least ${minPasswordLength} characters long`
  }
  if (password && passwordConfirmation.trim() !== password.trim()) {
    errors.passwordConfirmation = 'Password confirmation must match password'
  }

  return errors
}
Exemple #6
0
 _.forEach(formData, function(val, key) {
   if (key == 'email') {
     if (isEmail(val)) {
       form[key] = true;
     } else {
       form[key] = false;
     }
   } else {
     if (val != '') {
       form[key] = true;
     } else {
       form[key] = false;
     }
   }
 }.bind(this));
function validate(formProps) {
  const errors = {}
  if (!formProps.email) {
    errors.email = 'Please enter an email'
  }

  if (!formProps.password) {
    errors.password = 'Please enter a password'
  }

  if (formProps.email && isEmail(formProps.email) === false) {
    errors.email = 'Please enter a valid email'
  }

  return errors
}
Exemple #8
0
  validate = () => {
    if (!isEmail(this.state.email)) {
      ToastAndroid.show('Invalid email address.', ToastAndroid.SHORT)
      return false
    } else if (!isLength(this.state.password, { min: 6, max: 32 })) {
      ToastAndroid.show('Length of Password should between 6 and 32.', ToastAndroid.SHORT)
      return false
    } else if (this.state.password !== this.state.passwordR) {
      ToastAndroid.show('Confirm Password is different.', ToastAndroid.SHORT)
      return false
    } else if (!isLength(this.state.code, { min: 1 })) {
      ToastAndroid.show('Code can\'t be empty.', ToastAndroid.SHORT)
      return false
    }

    return true
  }
function validate ( formProps ) {

    const errors = {};

    const email = formProps.email ? formProps.email : '';

    // TODO: map over the formProps object to clean this up.

    if ( !formProps.email ) {
        errors.email = 'Please enter an email';
    }

    if ( !formProps.password ) {
        errors.password = 'Please enter a password';
    }

    if ( !formProps.passwordConfirm ) {
        errors.passwordConfirm = 'Please confirm your password';
    }

    if ( !isEmail( email ) ) {
        errors.email = 'Please enter a valid email';
    } else {
        mailcheck.run({
            email,
            domains,
            secondLevelDomains,
            topLevelDomains,
            suggested: function(suggestion) {
                errors.email = 'Did you mean ' +  suggestion.full + '?';
            },
            empty: function() {
                errors.email = '';
            }
        });
    }

    if ( formProps.password !== formProps.passwordConfirm ) {
        errors.password = 'Passwords must match';
    }

    return errors;

}
Exemple #10
0
router.post('/login', (req, res) => {
  if(!isEmail(req.body.username)){
    return res.status(500).send({message:"Not a valid email address"})
  }
  passport.authenticate('local-login', function(err, user, info) {
    if (err) {
      return res.status(500).send(err);
    }
    if (!user) {
      return res.status(401).send(info);
    }
    req.login(user, loginErr => {
      if (loginErr) {
        return res.status(500).send(loginErr);
      }
      res.json({Status:"Ok"})
    });
  })(req, res);
});
Exemple #11
0
  sendEmail = () => {
    if (isEmail(this.state.email)) {

      this.setState({
        getCodeDisable: true
      })

      // console.log(`${SENDEMAIL_URL}?email=${this.state.email}`);
      easyFetch(SENDEMAIL_URL, {
        email: this.state.email
      }).then(response => {
        if (response.ok) {
          ToastAndroid.show('Email sent successfully', ToastAndroid.SHORT)
        } else {
          resolveErrorResponse(response)
        }

        this.setState({
          countDown: 60
        })

        this.timer = this.setInterval(() => {
          this.setState({
            countDown: this.state.countDown - 1
          })
          if (this.state.countDown <= 0) {
            this.clearInterval(this.timer)
            this.setState({
              getCodeDisable: false
            })
          }
        }, 1000)
      }).catch(err => {
        ToastAndroid.show(err.message, ToastAndroid.SHORT)
        this.setState({
          getCodeDisable: false
        })
      })
    } else {
      ToastAndroid.show('Email is invalid.', ToastAndroid.SHORT)
    }
  }
Exemple #12
0
    Object.keys(fields).forEach(n => {
      const f = fields[n];
      if (n === name) {
        f.value = value;
      }

      if (f.required) {
        if (f.value == null || f.value === '' || f.value.length === 0) {
          f.error = 'required';
          valid = false;
        } else {
          f.error = null;
        }
      }
      if (f.email && f.error !== 'required') {
        if (!isEmail(f.value)) {
          f.error = 'email';
          valid = false;
        } else {
          f.error = null;
        }
      }
      if (f.phone && f.error !== 'required') {
        try {
          const num = this.phoneUtil.parse(f.value, '');
          const isPhoneValid = this.phoneUtil.isValidNumber(num, PhoneNumberFormat.E164);
          if (isPhoneValid) {
            f.error = null;
          } else {
            f.error = 'phone';
            valid = false;
          }
        } catch (err) {
          f.error = 'phone';
          valid = false;
        }
      }
    });
Exemple #13
0
export const email /*: Validator<string> */ = value => {
  if (value.length === 0) return { type: 'required' };
  if (!isEmail(value)) return { type: 'email' };
};
Exemple #14
0
export function email(value) {
  return value && !isEmail(value.trim()) ? 'Invalid email' : null;
}
Exemple #15
0
export default (email) => isEmail(email);
    maxlength: [
      DEFAULT_MAX_LENGTH,
      `Last name is too long (maximum is ${DEFAULT_MAX_LENGTH} characters)`,
    ],
  },
}

export const emailValidator = {
  type: String,
  unique: true,
  required: [true, 'Please provide a valid email.'],
  validate: {
    validator(email) {
      return isEmail(email, {
        allow_display_name: false,
        require_display_name: false,
        allow_utf8_local_part: true,
        require_tld: true,
      })
    },
    message: 'Please enter your email address.',
  },
}

export const passwordValidator = {
  type: String,
  required: [true, 'Please enter a password.'],
  minlength: [8, 'Password is too short (minimum is 8 characters)'],
  maxlength: [
    DEFAULT_MAX_LENGTH,
    `Password is too long (maximum is ${DEFAULT_MAX_LENGTH} characters)`,
  ],
Exemple #17
0
export const isEmail = (value) => (checkIsEmail(value) ? null : 'form.error.email');
  genderChange(event) {
    let value = event.target.value;
    this.setState({gender: value});
  },

  validNumberOfAge(){
    let { age } = this.state;

    if (!age|| !isNaN(age)|| isNumeric(age)) return '';
    if (!isNumeric(age)) return 'error';
  },

  validEmail(){
    let { email } = this.state;

    if (!email|| !isNaN(email)|| isEmail(email)) return '';
    if (!isEmail(email)) return 'error';
  },

  render(){
    return (
      <div className="person-step">
        <h3>Add Person to Homehold</h3>

        <form onSubmit={this.onSubmitHandler} className="form-inline">

          <div className="form-group padding-bottom-8">
            <div className="form-group">
              <label htmlFor="firstName" className="padding-both-8">First Name</label>
              <input type="input" onChange={this.handleChange} name="firstName" id="firstName" placeholder="First name" className="form-control" required/>
            </div>
 return function isEmail(value, callback) {
   const valid = !value || isEmail(value, options);
   const response = valid ? null : message ;
   callback(response);
 }
Exemple #20
0
 validator: function(v) {
   return isEmail(v);
 },
Exemple #21
0
export default (input, options) => isCreditCard(String(input), options)