fix error in validation and undefined email value

This commit is contained in:
GotPPay
2018-01-19 20:15:27 +01:00
parent 00272ec67d
commit 434d45248c
2 changed files with 7 additions and 5 deletions

View File

@@ -9,6 +9,7 @@ module.exports = {
//dot = .
//TODO: This list should be longer
let transformedEmail = email
.replace (/\s/g, '') //remove all spaces
.replace (/at/gi, '@')
.replace (/underscore/gi, '_')
.replace (/dash/gi, '-')
@@ -17,10 +18,11 @@ module.exports = {
return transformedEmail;
},
isEmailValid : function(email){
let validEmailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
isEmailValid: function (email) {
console.log ('Email to validate : ' + email);
let validEmailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return validEmailRegex.test(email);
return validEmailRegex.test (email);
},
sendEmal: function (name, fromEmail, message, toEmail) {
@@ -59,7 +61,7 @@ module.exports = {
to: toEmail,
subject: 'Message from Saburly service',
text: messageBody,
html: messageBodyHTML
html: messageBodyHTML,
};
transporter.sendMail (mailOptions, (error, info) => {

View File

@@ -88,7 +88,7 @@ module.exports = {
repromptSpeech
);
} else if (!intent.slots.Message.value) {
intent.slots.Email.value = emailHelper.transformEmailFromAlexaResponse(intent.slots.Message.value);
intent.slots.Email.value = emailHelper.transformEmailFromAlexaResponse(intent.slots.Email.value);
if (
!emailHelper.isEmailValid (
intent.slots.Email.value