const settingsList = connect(mapStateToProps, (dispatch, props) => { return { resetToken(user) { return () => dispatch(resetBadgeTokenForUser(user)); }, changeLongWorkPeriodDuration(event) { let setting = { long_work_period: event.target.value }; // update the setting locally, and push the change remotely. dispatch(changeSetting(setting)); dispatch(preemptiveSettingUpdate(setting)); }, validateEmail(email) { return EmailValidator.validate(email); }, changePaymentEmail(event) { let value = event.target.value; let setting = { payment_email: value }; // update the setting locally, and push the change remotely. dispatch(changeSetting(setting)); dispatch(preemptiveSettingUpdate(setting)); }, }; })(settingsListComponent);
router.post('/create_user', function(req, res) { var newUser = new User(); if (!validator.validate(req.body.email)) { return res.json({errorCode: 2, msg: 'A valid email address is required'}); } newUser.username = req.body.username; newUser.basic.email = req.body.email; newUser.generateUuid(); newUser.generateHash(req.body.password, function(err, hash) { if (err) { return res.status(500).json({msg: 'Account could not be created'}); } newUser.basic.password = hash; newUser.save(function(err, user) { if (err) { console.log(err); return res.status(500).json({msg: 'Account could not be created'}); } // Return a token newUser.generateToken(process.env.APP_SECRET, function(err, token) { if (err) { console.log(err); return res.status(500).json({msg: 'Internal Server Error'}); } res.status(200).json({token: token}); }); }); }); });
email: ['username', function (done, results) { let validationError = Error('Email validation failed.'); if (!req.body.hasOwnProperty('email')) { reply.errors.push('`email` is required'); } else if (!ValidEmail(req.body.email)) { reply.errors.push('`email` has an invalid format'); } if (reply.errors.length > 0) { res.status(400); return done(validationError); } let email = req.body.email; let query = 'SELECT id FROM users WHERE email = $1'; req.app.db.run(query, [email], (err, result) => { if (err) { res.status(500); reply.errors.push('exception encountered'); return done(err); } if (result.rows.length !== 0) { res.status(400); reply.errors.push(`\`email\` (${email}) already in use`); return done(validationError); } done(null, email); }); }],
render() { const { timeMs } = this.props.result; const { name, email } = this.state; const formValid = name && emailValidator.validate(email); return ( <div className="Inscription"> <h1>Bravo ({timeMs} ms)</h1> <form> <div className="form-group"> <input type="text" className="form-control" placeholder="Name" value={name} onChange={this.handleNameChange} /> </div> <div className="form-group"> <input type="email" className="form-control" placeholder="Email (to contact the winner!)" value={email} onChange={this.handleEmailChange} /> </div> <button className="btn" disabled={!formValid} onClick={this.handleRegister} > Ride for the prize </button> </form> </div> ); }
check: function (value, params, done) { if (!_.isString(value)) { return false; } return isEmail.validate(value); }
]).then((results) => { let email = flags.notify let emailPrompt const project = results[1] if (!email) { // if no email has been specified, read it from user config. // if no user config entry, prompt for an email and save the value emailPrompt = () => emailConfig.askIfNotSet() } else { if (!isValidEmail(email)) { return Promise.reject(new Error(`Email address "${email}" is invalid.`)) } // if an email has been specified, check for an entry in the user config // if nothing is found, save the email to global config emailPrompt = () => emailConfig.writeIfNotSet(email) } return emailPrompt().then((promptResults) => { email = email || promptResults return pluginHelper(src) .then(() => options.blinkMobileIdentity.assumeAWSRole({ bmProject: project, command: 'build', platforms })) .then((assumedRole) => { const passwords = new CertificatePasswords(platforms, buildMode, assumedRole) return passwords.get() .then((passwordsByPlatform) => upload(src, assumedRole).then((file) => go(platforms, email, file, assumedRole, passwordsByPlatform, buildMode))) }) }) })
LoginPage.prototype.signin = function (email) { console.info(email); if (!validator.validate(email)) { dialogs_1.alert("invalid email address"); } this._router.navigate(["Home"]); };
app.post('/api/users', function(req, res) { if (!validator.validate(req.body.email)) return res.send('Please enter a valid email'); //check if email exists or if username exists User.findOne({ $or: [ { 'basic.email': req.body.email }, { name: req.body.name } ] }, function(err, user) { if (err) return res.status(500).send('email or name is taken'); if (user) { if (user.basic.email === req.body.email) return res.send('email already existed'); else return res.send('username taken'); } //check if the password confirmation is match if (req.body.password !== req.body.passwordConfirm) return res.send('passwords did not match'); var newUser = new User(); newUser.name = req.body.name; newUser.basic.email = req.body.email; newUser.basic.password = newUser.generateHash(req.body.password); newUser.save(function(err) { if (err) return res.status(500).send('could not create user'); res.send({ jwt: newUser.generateToken(app.get('jwtSecret')) }); }); }); });
function(callback){ var opponent = {id: null, mail: null}; if(type=='byemail'){ opponent.mail = opponentname; return validator.validate(opponent.mail) ? callback(null, opponent) : callback(new HttpError(400, 'Incorrect email!')); } else { User.findOne({displayName: opponentname},function(err, data){ if(err) { return callback(err); } if(data){ if(data._id.equals(req.user._id)){ return callback(new HttpError(400, 'You cannot call youself!')); } opponent.id = data._id; opponent.mail = data.email; return callback(null, opponent); } else { return callback(new HttpError(400, 'Incorrect user name!')); } }); } },
router.post('/sendMail', function(req, res, next) { console.log(req.body) if(!req.body.name || !req.body.email || !req.body.subject || !req.body.msg){ return res.end(); } if(!validator.validate(req.body.email)){ return res.end(); } var mailOptions = { from: req.body.email, to: '"Message" <*****@*****.**>', subject: req.body.subject, text: 'Name: '+req.body.name+' // '+ 'Email: '+req.body.email+' // '+ 'Subject: '+req.body.subject+' // '+ 'Message: '+req.body.msg }; transporter.sendMail(mailOptions, function(error, info){ if(error){ console.log(error); } console.log('Message sent: '); res.end(); }); });
function onLoginButton() { var email = ractive.get('emailAddressInput') if (emailIsValid(email)) { emitter.emit('login', email) ractive.set('loggingIn', true) } else { emitter.emit('badEmail', email) } }
getToValidationError( email ) { email = email.trim(); if ( email.length === 0 ) { return false; // ignore the empty emails } if ( ! emailValidator.validate( email ) ) { return { email }; } return false; }
function validateField( { name, value } ) { switch ( name ) { case 'mailbox': return /^[a-z0-9._+-]{1,64}$/i.test( value ) && ! /(^\.)|(\.{2,})|(\.$)/.test( value ); case 'destination': return emailValidator.validate( value ); default: return true; } }
route.post('/ValidateEmail', function(req, res){ if (req.body.emailId){ var isValid = validator.validate("*****@*****.**"); if (isValid){ res.json({ succss: 1, message: 'Valid email' }) } } })
module.exports = function(email) { if (!email_is_valid(email)) throw new Error('Invalid email'); var cache = temp_mail_regex_list, i = cache.length; while(--i >= 0) { if ( cache[i].test(email) ) return true; } return false; };
this.validateEmail = function(callback){ console.log("\t validateEmail"); if(validator.validate(email_address)){ callback(null); } else{ callback({ "response_code": "M2", "message": "Invalid email address" }); } }
module.exports = (email) => { if (!email) { return null; } if (!validator.validate(email)) { return `E-mail ${email} is't valid`; } return null; };
validateEmail = event => { const { translate } = this.props; if ( ! emailValidator.validate( event.target.value ) ) { this.setState( { emailValidMessage: translate( 'Please enter a valid email address.' ), } ); } else { this.setState( { emailValidMessage: false, } ); } };
deserialize (value) { value = super.deserialize(value) if (!this.params.caseSensitive) { value = value.toLowerCase() } if (value && !validateEmail(value)) { throw new Field.ValidationError('Value must be a valid email address') } return value }
router.post('/login', (req, res)=> { "use strict"; let result = {}; if (!req.body.email || !req.body.email.length || !validator.validate(req.body.email)) { result.error = 'Email is not valid'; } else if (!req.body.password || !req.body.password.length) { result.error = 'Email is empty'; } else { req.session.autorized = true; result.result = {authorized: true}; } res.send(result); });
function renderJSONCalendar(req, res, next) { debug("renderPublicCalendar"); var email = req.query.email; if (!emailValidator.validate(email)) { return next(new Error("Please add your email to query. Thanks TheFive. " + email + " looks invalid.")); } fs.appendFileSync("Calendarusage.log", email + " " + new Date() + "\n"); parseEvent.calendarToJSON({}, function(err, result) { if (err) return next(err); res.json(result); }); }
const NotificationsOrigin = ( { item, recipient, onChange, loaded, checkEmail, translate, placeholder, } ) => { const change = ( { target: { value } } ) => { onChange( { setting: item.field, option: item.option, value, } ); }; const emailValidationError = checkEmail && recipient.length !== 0 && ! emailValidator.validate( recipient ); const placeholderComponent = <p className="components__is-placeholder" />; return ( <div className="components__notification-origin"> { loaded ? <FormLabel>{ item.title }</FormLabel> : placeholderComponent } <FormTextInput className={ ! loaded ? 'components__is-placeholder' : null } isError={ emailValidationError } name={ item.field } onChange={ change } value={ recipient } placeholder={ placeholder } /> { emailValidationError && ( <FormTextValidation isError={ true } text={ translate( '%(recipient)s is not a valid email address.', { args: { recipient }, } ) } /> ) } { loaded ? ( <FormSettingExplanation>{ item.subtitle }</FormSettingExplanation> ) : ( placeholderComponent ) } </div> ); };
app.post("/api/email", (req, res) => { if (validator.validate(req.body.email)) { console.log("valid email", req.body.email) knex .table("users") .insert({ email: req.body.email }) .then(r => res.send(r)) .then(() => sendEmail(req.body.email)) .catch(err => { console.error(err) res.status(500).send(err); }); } else { res.status(400).send({ err: "INVALID_EMAIL" }); } });
.then(function(body) { // check website URL expect(body.websiteURL).to.be.a('string'); website = body.websiteURL // check description expect(body.description).to.be.a('string'); // check email const email = body.supportemail expect(email).to.be.a('string'); expect(validator.validate(email)).to.equal(true); // check UUID const uuid = body.discoveryUUID; expect(uuid).to.be.a('string').and.to.have.length(36); });
register: function(req, res) { var alphanumeric = /^[a-zA-Z0-9]+$/; if (!alphanumeric.test(req.body.username)) { return res.status(403).json({ message: 'Your username must be alphanumeric' , csrfToken: req.csrfToken() }); } if (req.body.password.length < 6) { // Check password length return res.status(403).json({ message: 'Error: your password length is too short' , csrfToken: req.csrfToken() }); } if (!emailValid.validate(req.body.email)) { // make sure email is valid return res.status(403).json({ // if invalid email reload the page message: 'Error: The email address you submitted is invalid' , csrfToken: req.csrfToken() }); } User.register( // this should be valid register data new User({ username: req.body.username , email: req.body.email }), // pass info to schema req.body.password, function(err) { if (err && err.code === 11000) { // Duplicate key error of Mongoose return res.status(403).json({ message: 'I\'m sorry, but someone else has already registered with that email address.' , csrfToken: req.csrfToken() }); } if (err && err.code !== 11000) { // Other error return res.status(500).json({ message: err.message , csrfToken: req.csrfToken() }); } passport.authenticate('local')(req, res, function() { res.sendStatus(200); }); } ); },
validate: function (done) { if (!req.body.hasOwnProperty('email')) { reply.errors.push('`email` is required'); } else if (!ValidEmail(req.body.email)) { reply.errors.push('`email` has an invalid format'); } if (!req.body.hasOwnProperty('token')) { reply.errors.push('`token` is required'); } if (reply.errors.length === 0) { done(); } else { res.status(400); done(Error('Validation failed.')); } },
return mapValues( user, function( field, key ) { var error = null; if ( isEmpty( field.value ) ) { error = i18n.translate( 'This field is required.' ); } else if ( includes( [ 'firstName', 'lastName' ], key ) ) { if ( field.value.length > 60 ) { error = i18n.translate( 'This field can\'t be longer than 60 characters.' ); } } else if ( 'email' === key ) { if ( /[^[0-9a-z_'.-]/i.test( field.value ) ) { error = i18n.translate( 'Only number, letters, dashes, underscores, apostrophes and periods are allowed.' ); } else if ( ! emailValidator.validate( `${ field.value }@${ domainSuffix }` ) ) { error = i18n.translate( 'Please provide a valid email address.' ); } } return Object.assign( {}, field, { error: error } ); } );
app.post('/contact_us', function (req, res) { var name = req.body.name, email = req.body.email, company = req.body.company, message = req.body.message; if (!name || name.trim().length == 0 || name.length > 64) { return res.json({success : false, error: "Incorrect name"}); } if (!email || !emailValidator.validate(email)) { return res.json({success: false, error : "Incorrect email address"}); } if (company && (company.trim().length == 0 || company.length > 64)) { return res.json({success: false, error: "Incorrect company"}); } if (!message || message.trim().length == 0) { return res.json({success: false, error: "Incorrect message"}); } var message = 'Name: ' + name + "\n" + "Email: " + email + "\n" + (company? "Company: " + company + "\n" : "") + "Message: " + "\n" + message; var mailOptions = { from: 'Lisk Business <*****@*****.**>', // sender address replyTo: name + ' <' + email + '>', // reply to user to: '*****@*****.**', // list of receivers subject: 'Contact Message From Lisk.io', // subject line text: message }; transporter.sendMail(mailOptions, function(error, info){ if(error) { console.log(error); return res.json({success: false, error: "Failed to send message! Something went wrong on our server."}); } console.log('Message sent: ' + info.response); return res.json({success: true}); }); });
schema.pre('save', function (next) { if(!this.displayName) { this.displayName = this.username; } this.displayName = shorten(this.displayName); var err; if(this.email && !validator.validate(this.email)){ err = new Error('Wrong email!'); } var good=false; for(var i=0;i<langs.length;i++){ if(langs[i].lang == this.language){ good = true; } } if(!good){ err = new Error('Wrong language code!'); } next(err); });
isValidFile: function(file) { // validate is a jpeg var patt1 = /\.[jpeg|jpg]+$/ig; if (file.match(patt1) === null) { return false; } // get the name var parsed = path.parse(file); // validate email address if (!validator.validate(parsed.name)) { return false; } return true; },