Merge branch 'fix-invalid-email-crash' into 'master'
Fix invalid email crash See merge request saburly/marketalarm/web!62
This commit was merged in pull request #62.
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
@@ -15,8 +15,15 @@ const getRealEstateTypes = (req, res) => {
|
||||
const postRealEstateTypes = async (req, res) => {
|
||||
const searchRequest = await currentSearchRequest(req);
|
||||
|
||||
//TODO: check if selected real estate type is valid
|
||||
const validRealEstateTypes = Object.keys(AD_CATEGORY).filter(
|
||||
category => !!AD_CATEGORY[category].title
|
||||
);
|
||||
|
||||
const selectedRealEstateType = req.body.realEstateType || null;
|
||||
if (validRealEstateTypes.indexOf(selectedRealEstateType) === -1) {
|
||||
res.render("notFound", { title: " " });
|
||||
return;
|
||||
}
|
||||
|
||||
const nextStepPage = req.query.nextStep || "lokacija";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const isValidEmail = email => {
|
||||
const simpleEmailRegex = /^.+@.+\..+$/;
|
||||
const simpleEmailRegex = /^(([^<>()\[\]\\.,;:\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 email && email.length < 250 && simpleEmailRegex.test(email);
|
||||
};
|
||||
|
||||
|
||||
@@ -48,7 +48,20 @@
|
||||
<script>
|
||||
$(document).ready( () => {
|
||||
$("#submit").click( () => {
|
||||
$("#form-queryreview").submit();
|
||||
const simpleEmailRegex = /^(([^<>()\[\]\\.,;:\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,}))$/;
|
||||
const email = $("#email").val();
|
||||
const confirmEmail = $("#confirmEmail").val();
|
||||
|
||||
if (email !== confirmEmail){
|
||||
$("#error-label-email").text("Greška ! Unešeni emailovi nisu isti");
|
||||
return;
|
||||
}
|
||||
|
||||
if (simpleEmailRegex.test(email)){
|
||||
$("#form-queryreview").submit();
|
||||
}else{
|
||||
$("#error-label-email").text("Greška ! Unešeni emailovi nisu isti");
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user