mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 09:06:15 +01:00
@@ -231,92 +231,75 @@ User.addInterstitials = function (callback) {
|
|||||||
hook: 'filter:register.interstitial',
|
hook: 'filter:register.interstitial',
|
||||||
method: [
|
method: [
|
||||||
// GDPR information collection/processing consent + email consent
|
// GDPR information collection/processing consent + email consent
|
||||||
function (data, callback) {
|
async function (data) {
|
||||||
if (!meta.config.gdpr_enabled) {
|
if (!meta.config.gdpr_enabled || (data.userData && data.userData.gdpr_consent)) {
|
||||||
return setImmediate(callback, null, data);
|
return data;
|
||||||
}
|
}
|
||||||
if (!data.userData) {
|
if (!data.userData) {
|
||||||
return setImmediate(callback, new Error('[[error:invalid-data]]'));
|
throw new Error('[[error:invalid-data]]');
|
||||||
}
|
}
|
||||||
const add = function () {
|
|
||||||
data.interstitials.push({
|
|
||||||
template: 'partials/gdpr_consent',
|
|
||||||
data: {
|
|
||||||
digestFrequency: meta.config.dailyDigestFreq,
|
|
||||||
digestEnabled: meta.config.dailyDigestFreq !== 'off',
|
|
||||||
},
|
|
||||||
callback: function (userData, formData, next) {
|
|
||||||
if (formData.gdpr_agree_data === 'on' && formData.gdpr_agree_email === 'on') {
|
|
||||||
userData.gdpr_consent = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
next(userData.gdpr_consent ? null : new Error('[[register:gdpr_consent_denied]]'));
|
if (data.userData.uid) {
|
||||||
},
|
const consented = await db.getObjectField('user:' + data.userData.uid, 'gdpr_consent');
|
||||||
});
|
if (parseInt(consented, 10)) {
|
||||||
};
|
return data;
|
||||||
|
|
||||||
if (!data.userData.gdpr_consent) {
|
|
||||||
if (data.userData.uid) {
|
|
||||||
db.getObjectField('user:' + data.userData.uid, 'gdpr_consent', function (err, consented) {
|
|
||||||
if (err) {
|
|
||||||
return callback(err);
|
|
||||||
} else if (!parseInt(consented, 10)) {
|
|
||||||
add();
|
|
||||||
}
|
|
||||||
|
|
||||||
callback(null, data);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
add();
|
|
||||||
setImmediate(callback, null, data);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// GDPR consent signed
|
|
||||||
setImmediate(callback, null, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.interstitials.push({
|
||||||
|
template: 'partials/gdpr_consent',
|
||||||
|
data: {
|
||||||
|
digestFrequency: meta.config.dailyDigestFreq,
|
||||||
|
digestEnabled: meta.config.dailyDigestFreq !== 'off',
|
||||||
|
},
|
||||||
|
callback: function (userData, formData, next) {
|
||||||
|
if (formData.gdpr_agree_data === 'on' && formData.gdpr_agree_email === 'on') {
|
||||||
|
userData.gdpr_consent = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
next(userData.gdpr_consent ? null : new Error('[[register:gdpr_consent_denied]]'));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return data;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Forum Terms of Use
|
// Forum Terms of Use
|
||||||
function (data, callback) {
|
async function (data) {
|
||||||
if (!data.userData) {
|
if (!data.userData) {
|
||||||
return setImmediate(callback, new Error('[[error:invalid-data]]'));
|
throw new Error('[[error:invalid-data]]');
|
||||||
|
}
|
||||||
|
if (!meta.config.termsOfUse || data.userData.acceptTos) {
|
||||||
|
// no ToS or ToS accepted, nothing to do
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const add = function () {
|
if (data.userData.uid) {
|
||||||
data.interstitials.push({
|
const accepted = await db.getObjectField('user:' + data.userData.uid, 'acceptTos');
|
||||||
template: 'partials/acceptTos',
|
if (parseInt(accepted, 10)) {
|
||||||
data: {
|
return data;
|
||||||
termsOfUse: meta.config.termsOfUse,
|
|
||||||
},
|
|
||||||
callback: function (userData, formData, next) {
|
|
||||||
if (formData['agree-terms'] === 'on') {
|
|
||||||
userData.acceptTos = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
next(userData.acceptTos ? null : new Error('[[register:terms_of_use_error]]'));
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
if (meta.config.termsOfUse && !data.userData.acceptTos) {
|
|
||||||
if (data.userData.uid) {
|
|
||||||
db.getObjectField('user:' + data.userData.uid, 'acceptTos', function (err, accepted) {
|
|
||||||
if (err) {
|
|
||||||
return callback(err);
|
|
||||||
} else if (!parseInt(accepted, 10)) {
|
|
||||||
add();
|
|
||||||
}
|
|
||||||
|
|
||||||
callback(null, data);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
add();
|
|
||||||
setImmediate(callback, null, data);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// TOS accepted
|
|
||||||
setImmediate(callback, null, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const termsOfUse = await plugins.fireHook('filter:parse.post', {
|
||||||
|
postData: {
|
||||||
|
content: meta.config.termsOfUse || '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
data.interstitials.push({
|
||||||
|
template: 'partials/acceptTos',
|
||||||
|
data: {
|
||||||
|
termsOfUse: termsOfUse.postData.content,
|
||||||
|
},
|
||||||
|
callback: function (userData, formData, next) {
|
||||||
|
if (formData['agree-terms'] === 'on') {
|
||||||
|
userData.acceptTos = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
next(userData.acceptTos ? null : new Error('[[register:terms_of_use_error]]'));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return data;
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user