improve email regex; improve error handling for query review

This commit is contained in:
Bilal Catic
2019-10-28 12:34:14 +01:00
parent 43877820cf
commit dd8e4d77ed
3 changed files with 47 additions and 4 deletions

View File

@@ -122,9 +122,39 @@ const postQueryReview = async (req, res) => {
searchRequest.email = emailInput;
searchRequest.subscribed = true;
await searchRequest.save();
await notifyForNewSearchRequest(searchRequest);
try {
await searchRequest.save();
} catch (e) {
console.log("[ERROR] Failed to save search request !", e);
console.log("Search request : ", searchRequest);
const error =
"Greška ! Nismo uspjeli kreirati zahtjev za Vašu pretragu. Molimo pokuštajte ponovo";
res.render("queryReview", {
error,
title,
queryReviewData,
email: ""
});
return;
}
try {
await notifyForNewSearchRequest(searchRequest);
} catch (e) {
console.log("[ERROR] Failed to send initial welcome email", e);
console.log("Search request : ", searchRequest);
const error =
"Greška ! Nismo uspjeli poslati email na Vašu adresu, pokušajte sa drugom email adresom";
res.render("queryReview", {
error,
title,
queryReviewData,
email: ""
});
return;
}
res.redirect(nextStep);
};