+28
-14
@@ -461,7 +461,7 @@
|
||||
if (window.grecaptcha && reCaptchaSiteKey) {
|
||||
grecaptcha.ready(function () {
|
||||
grecaptcha.execute(reCaptchaSiteKey, {
|
||||
action: 'contact'
|
||||
action: 'cv_upload'
|
||||
}).then(postCv);
|
||||
});
|
||||
} else {
|
||||
@@ -470,7 +470,7 @@
|
||||
$button.prop('disabled', false).text(t('cv.submit'));
|
||||
return;
|
||||
}
|
||||
function postCv(token) {
|
||||
async function postCv(token) {
|
||||
try {
|
||||
var formData = new FormData();
|
||||
formData.append('cv', file);
|
||||
@@ -482,19 +482,33 @@
|
||||
});
|
||||
if (!cvResponse.ok) throw new Error(t('cv.cvFailed'));
|
||||
var cvData = await cvResponse.json();
|
||||
// Before calling match, obtain a fresh captcha token for the match action
|
||||
if (!(window.grecaptcha && reCaptchaSiteKey)) {
|
||||
throw new Error(t('form.captchaFailed'));
|
||||
}
|
||||
|
||||
// get match token
|
||||
var matchToken = await new Promise(function (resolve, reject) {
|
||||
try {
|
||||
grecaptcha.ready(function () {
|
||||
grecaptcha.execute(reCaptchaSiteKey, { action: 'match_job' }).then(resolve).catch(reject);
|
||||
});
|
||||
} catch (e) { reject(e); }
|
||||
});
|
||||
|
||||
var matchResponse = await fetch('/api/cv-matcher/match-job', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
cvDocumentId: cvData.documentId || cvData.cvDocumentId,
|
||||
jobUrl: jobUrl,
|
||||
jobDescription: jobDescription,
|
||||
gdprConsent: consent,
|
||||
captchaToken: token
|
||||
})
|
||||
});
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
cvDocumentId: cvData.documentId || cvData.cvDocumentId,
|
||||
jobUrl: jobUrl,
|
||||
jobDescription: jobDescription,
|
||||
gdprConsent: consent,
|
||||
captchaToken: matchToken
|
||||
})
|
||||
});
|
||||
if (!matchResponse.ok) throw new Error(t('cv.matchFailed'));
|
||||
var match = await matchResponse.json();
|
||||
renderMatchResult(match);
|
||||
|
||||
Reference in New Issue
Block a user