mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 17:16:14 +01:00
fix: errors from registerComplete
This commit is contained in:
@@ -138,16 +138,14 @@ async function addToApprovalQueue(req, userData) {
|
|||||||
return { message: message };
|
return { message: message };
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticationController.registerComplete = function (req, res, next) {
|
authenticationController.registerComplete = async function (req, res) {
|
||||||
|
try {
|
||||||
// For the interstitials that respond, execute the callback with the form body
|
// For the interstitials that respond, execute the callback with the form body
|
||||||
plugins.hooks.fire('filter:register.interstitial', {
|
const data = await plugins.hooks.fire('filter:register.interstitial', {
|
||||||
req,
|
req,
|
||||||
userData: req.session.registration,
|
userData: req.session.registration,
|
||||||
interstitials: [],
|
interstitials: [],
|
||||||
}, async (err, data) => {
|
});
|
||||||
if (err) {
|
|
||||||
return next(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
const callbacks = data.interstitials.reduce((memo, cur) => {
|
const callbacks = data.interstitials.reduce((memo, cur) => {
|
||||||
if (cur.hasOwnProperty('callback') && typeof cur.callback === 'function') {
|
if (cur.hasOwnProperty('callback') && typeof cur.callback === 'function') {
|
||||||
@@ -165,13 +163,10 @@ authenticationController.registerComplete = function (req, res, next) {
|
|||||||
return memo;
|
return memo;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const done = function (err, data) {
|
const done = function (data) {
|
||||||
delete req.session.registration;
|
delete req.session.registration;
|
||||||
if (err) {
|
|
||||||
return res.redirect(`${nconf.get('relative_path')}/?register=${encodeURIComponent(err.message)}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!err && data && data.message) {
|
if (data && data.message) {
|
||||||
return res.redirect(`${nconf.get('relative_path')}/?register=${encodeURIComponent(data.message)}`);
|
return res.redirect(`${nconf.get('relative_path')}/?register=${encodeURIComponent(data.message)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,8 +194,7 @@ authenticationController.registerComplete = function (req, res, next) {
|
|||||||
if (!data) {
|
if (!data) {
|
||||||
return winston.warn('[register] Interstitial callbacks processed with no errors, but one or more interstitials remain. This is likely an issue with one of the interstitials not properly handling a null case or invalid value.');
|
return winston.warn('[register] Interstitial callbacks processed with no errors, but one or more interstitials remain. This is likely an issue with one of the interstitials not properly handling a null case or invalid value.');
|
||||||
}
|
}
|
||||||
|
done(data);
|
||||||
done(null, data);
|
|
||||||
} else {
|
} else {
|
||||||
// Update user hash, clear registration data in session
|
// Update user hash, clear registration data in session
|
||||||
const payload = req.session.registration;
|
const payload = req.session.registration;
|
||||||
@@ -217,7 +211,10 @@ authenticationController.registerComplete = function (req, res, next) {
|
|||||||
await user.setUserFields(uid, payload);
|
await user.setUserFields(uid, payload);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
});
|
} catch (err) {
|
||||||
|
delete req.session.registration;
|
||||||
|
res.redirect(`${nconf.get('relative_path')}/?register=${encodeURIComponent(err.message)}`);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
authenticationController.registerAbort = function (req, res) {
|
authenticationController.registerAbort = function (req, res) {
|
||||||
|
|||||||
Reference in New Issue
Block a user