mirror of
https://github.com/optim-enterprises-bv/databunker.git
synced 2025-11-02 02:48:05 +00:00
Refactor accept agreement
This commit is contained in:
@@ -174,3 +174,25 @@ function loadAgreements(method, address, cb) {
|
||||
}
|
||||
xhr1.send();
|
||||
}
|
||||
|
||||
function acceptAgreement(method, address, brief, options, cb) {
|
||||
var xhr1 = new XMLHttpRequest();
|
||||
var params = '';
|
||||
if (options) {
|
||||
params = JSON.stringify(options);
|
||||
}
|
||||
xhr1.open('POST', "/v1/agreement/" + brief + "/" + method + "/" + address);
|
||||
xhr1.setRequestHeader("X-Bunker-Token", xtoken)
|
||||
xhr1.setRequestHeader('Content-type', 'application/json');
|
||||
xhr1.onload = function() {
|
||||
if (xhr1.status === 200) {
|
||||
var data = JSON.parse(xhr1.responseText);
|
||||
if (cb) {
|
||||
cb(data);
|
||||
}
|
||||
} else if (xhr1.status > 400 && xhr1.status < 500) {
|
||||
document.location = "/";
|
||||
}
|
||||
}
|
||||
xhr1.send(params);
|
||||
}
|
||||
|
||||
@@ -85,18 +85,9 @@ function withdrawConsent(brief) {
|
||||
}
|
||||
|
||||
function acceptConsent(brief) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', "/v1/agreement/" + brief + "/token/" + token);
|
||||
xhr.setRequestHeader("X-Bunker-Token", xtoken)
|
||||
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||
xhr.onload = function() {
|
||||
if (xhr.status === 200) {
|
||||
document.location.reload();
|
||||
} else if (xhr.status > 400 && xhr.status < 500) {
|
||||
document.location = "/";
|
||||
}
|
||||
}
|
||||
xhr.send();
|
||||
acceptAgreement('token', token, brief, '', function(data) {
|
||||
document.location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
function prepareRow(row) {
|
||||
|
||||
Reference in New Issue
Block a user