fix error in validation and undefined email value
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user