Skip to content

Commit

Permalink
update consent 14102024_sm
Browse files Browse the repository at this point in the history
  • Loading branch information
hopdxGms committed Oct 14, 2024
1 parent 9a41c7d commit e384e77
Showing 1 changed file with 46 additions and 30 deletions.
76 changes: 46 additions & 30 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
var tokenCaptcha;
var scriptCaptcha = document.createElement('script');
scriptCaptcha.setAttribute('src', `https://www.google.com/recaptcha/api.js?render=6LcCMl4qAAAAAMLgG-uhh5lRFswvMEDzIlxG1IOC`)
document.head.appendChild(scriptCaptcha);
grecaptcha.ready(function() {
grecaptcha.execute('6LcCMl4qAAAAAMLgG-uhh5lRFswvMEDzIlxG1IOC', {action: 'submit'}).then(function(token) {
tokenCaptcha = token;
});
});
console.log(tokenCaptcha);


//Setup uuid as device_key
var localKeyId = localStorage.getItem('deviceId');
Expand Down Expand Up @@ -172,29 +166,51 @@ if (null != appendingNode) {
null != t[0].value && null != t[1].value && n.push(`${t[0].value}${t[1].value}`);
}),
n.length > 0 && (n = n.join(",")),
document.querySelector("#gdprConsentAds-input").checked ? t = 1 : t = 0;
document.querySelector("#gdprConsentAds-input").checked ? t = 1 : t = 0;
scriptCaptcha.innerHTML = `
grecaptcha.ready(function() {
grecaptcha.execute('6LcCMl4qAAAAAMLgG-uhh5lRFswvMEDzIlxG1IOC',{action:'submit'}).then(function(token) {
// Append the reCAPTCHA token to the form data
data['TOKEN'] = token;
data['SOURCE'] = '${a}'
data['PLATFORM'] = '${c}'
data['SUB'] = ${t}
data['EMAIL'] = ${e}
data['PHONE'] = '${n}'
data['LAST-NAME'] = '${document.querySelector("input[id$='PersonalInfolastName']").value}'
data['FIRST-NAME'] = '${document.querySelector("input[id$='PersonalInfofirstName']").value}'
// Send the data to your API using fetch (or you can use axios)
var xhr = new XMLHttpRequest();
xhr.open("POST", "https://mssf.vietnamairlines.com:9001/consent-refx", true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(JSON.stringify(data));
})
});
`;
document.head.appendChild(scriptCaptcha);
// var token = await fetch('https://www.google.com/recaptcha/api.js?render=6LcCMl4qAAAAAMLgG-uhh5lRFswvMEDzIlxG1IOC');
await fetch("https://mssf.vietnamairlines.com:4443/api/v1.0/consent", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer bc3e3afb-f4ec-31ae-9570-f961b2f1fe75"
},
body: JSON.stringify({
SOURCE: a,
PLATFORM: c,
SUB: t,
EMAIL: e,
PHONE: n,
"LAST-NAME": document.querySelector("input[id$='PersonalInfolastName']").value,
"FIRST-NAME": document.querySelector("input[id$='PersonalInfofirstName']").value,
VENDOR: "GMS",
LANGUAGE: len,
COUNTRY: countryCode,
"DEVICE-ID": localKeyId,
"GA-ID": gaGlobal ? gaGlobal.vid : '',
token: token
}),
});
// await fetch("https://mssf.vietnamairlines.com:4443/api/v1.0/consent", {
// method: "POST",
// headers: {
// "Content-Type": "application/json",
// Authorization: "Bearer bc3e3afb-f4ec-31ae-9570-f961b2f1fe75"
// },
// body: JSON.stringify({
// SOURCE: a,
// PLATFORM: c,
// SUB: t,
// EMAIL: e,
// PHONE: n,
// "LAST-NAME": document.querySelector("input[id$='PersonalInfolastName']").value,
// "FIRST-NAME": document.querySelector("input[id$='PersonalInfofirstName']").value,
// VENDOR: "GMS",
// LANGUAGE: len,
// COUNTRY: countryCode,
// "DEVICE-ID": localKeyId,
// "GA-ID": gaGlobal ? gaGlobal.vid : '',
// token: token
// }),
// });
});
}

0 comments on commit e384e77

Please sign in to comment.