mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
closes #6483
This commit is contained in:
@@ -191,8 +191,18 @@ authenticationController.registerComplete = function (req, res, next) {
|
|||||||
res.locals.processLogin = true;
|
res.locals.processLogin = true;
|
||||||
registerAndLoginUser(req, res, req.session.registration, done);
|
registerAndLoginUser(req, res, req.session.registration, done);
|
||||||
} else {
|
} else {
|
||||||
// Clear registration data in session
|
// Update user hash, clear registration data in session
|
||||||
done();
|
const payload = req.session.registration;
|
||||||
|
const uid = payload.uid;
|
||||||
|
delete payload.uid;
|
||||||
|
|
||||||
|
Object.keys(payload).forEach((prop) => {
|
||||||
|
if (typeof payload[prop] === 'boolean') {
|
||||||
|
payload[prop] = payload[prop] ? 1 : 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
user.setUserFields(uid, payload, done);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ Controllers.registerInterstitial = function (req, res, next) {
|
|||||||
if (!data.interstitials.length) {
|
if (!data.interstitials.length) {
|
||||||
// No interstitials, redirect to home
|
// No interstitials, redirect to home
|
||||||
delete req.session.registration;
|
delete req.session.registration;
|
||||||
return res.redirect('/');
|
return res.redirect(nconf.get('relative_path') + '/');
|
||||||
}
|
}
|
||||||
var renders = data.interstitials.map(function (interstitial) {
|
var renders = data.interstitials.map(function (interstitial) {
|
||||||
return async.apply(req.app.render.bind(req.app), interstitial.template, interstitial.data || {});
|
return async.apply(req.app.render.bind(req.app), interstitial.template, interstitial.data || {});
|
||||||
|
|||||||
@@ -215,6 +215,9 @@ module.exports = function (middleware) {
|
|||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
if (!req.path.endsWith('/register/complete')) {
|
if (!req.path.endsWith('/register/complete')) {
|
||||||
|
// Append user data if present
|
||||||
|
req.session.registration.uid = req.uid;
|
||||||
|
|
||||||
controllers.helpers.redirect(res, '/register/complete');
|
controllers.helpers.redirect(res, '/register/complete');
|
||||||
} else {
|
} else {
|
||||||
return next();
|
return next();
|
||||||
|
|||||||
@@ -66,7 +66,11 @@ Auth.reloadRoutes = function (callback) {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
router.get(strategy.callbackURL, passport.authenticate(strategy.name, {
|
router.get(strategy.callbackURL, function (req, res, next) {
|
||||||
|
// Trigger registration interstitial checks
|
||||||
|
req.session.registration = req.session.registration || {};
|
||||||
|
next();
|
||||||
|
}, passport.authenticate(strategy.name, {
|
||||||
successReturnToOrRedirect: nconf.get('relative_path') + (strategy.successUrl !== undefined ? strategy.successUrl : '/'),
|
successReturnToOrRedirect: nconf.get('relative_path') + (strategy.successUrl !== undefined ? strategy.successUrl : '/'),
|
||||||
failureRedirect: nconf.get('relative_path') + (strategy.failureUrl !== undefined ? strategy.failureUrl : '/login'),
|
failureRedirect: nconf.get('relative_path') + (strategy.failureUrl !== undefined ? strategy.failureUrl : '/login'),
|
||||||
}));
|
}));
|
||||||
|
|||||||
48
src/user.js
48
src/user.js
@@ -353,7 +353,7 @@ User.addInterstitials = function (callback) {
|
|||||||
method: [
|
method: [
|
||||||
// GDPR information collection/processing consent + email consent
|
// GDPR information collection/processing consent + email consent
|
||||||
function (data, callback) {
|
function (data, callback) {
|
||||||
if (!data.userData.gdpr_consent) {
|
const add = function () {
|
||||||
data.interstitials.push({
|
data.interstitials.push({
|
||||||
template: 'partials/gdpr_consent',
|
template: 'partials/gdpr_consent',
|
||||||
data: {
|
data: {
|
||||||
@@ -368,14 +368,32 @@ User.addInterstitials = function (callback) {
|
|||||||
next(userData.gdpr_consent ? null : new Error('[[register:gdpr_consent_denied]]'));
|
next(userData.gdpr_consent ? null : new Error('[[register:gdpr_consent_denied]]'));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
setImmediate(callback, null, 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);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Forum Terms of Use
|
// Forum Terms of Use
|
||||||
function (data, callback) {
|
function (data, callback) {
|
||||||
if (meta.config.termsOfUse && !data.userData.acceptTos) {
|
const add = function () {
|
||||||
data.interstitials.push({
|
data.interstitials.push({
|
||||||
template: 'partials/acceptTos',
|
template: 'partials/acceptTos',
|
||||||
data: {
|
data: {
|
||||||
@@ -389,9 +407,27 @@ User.addInterstitials = function (callback) {
|
|||||||
next(userData.acceptTos ? null : new Error('[[register:terms_of_use_error]]'));
|
next(userData.acceptTos ? null : new Error('[[register:terms_of_use_error]]'));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
setImmediate(callback, null, data);
|
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);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ module.exports = function (User) {
|
|||||||
banned: 0,
|
banned: 0,
|
||||||
status: 'online',
|
status: 'online',
|
||||||
gdpr_consent: data.gdpr_consent === true ? 1 : 0,
|
gdpr_consent: data.gdpr_consent === true ? 1 : 0,
|
||||||
|
acceptTos: data.acceptTos === true ? 1 : 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
User.uniqueUsername(userData, next);
|
User.uniqueUsername(userData, next);
|
||||||
|
|||||||
Reference in New Issue
Block a user