Molodetz blogrol volgens DPP-template

This commit is contained in:
2026-10-05 09:36:20 +02:00
commit f290a4c766
277 changed files with 15758 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
// retoor <retoor@molodetz.nl>
export class TermsGate {
constructor(dialog) {
this.dialog = dialog;
this.pending = null;
}
async intercept(response) {
const payload = await response.json().catch(() => ({}));
if (payload.error?.code !== "terms_required") {
return false;
}
if (!this.pending) {
this.pending = this.dialog
.confirm(`De voorwaarden zijn gewijzigd (versie ${payload.error.terms_version}). Accepteren en doorgaan?`)
.then(async (accepted) => {
if (!accepted) {
return false;
}
const result = await fetch("/voorwaarden/accept", {
method: "POST",
credentials: "same-origin",
headers: { Accept: "application/json", "Content-Type": "application/json" },
body: "{}",
});
return result.ok;
})
.finally(() => {
setTimeout(() => { this.pending = null; }, 0);
});
}
return this.pending;
}
}