Skip to content

Node.js based forum software built for the modern web

fix: add missing await on filter:user.logout

Barış Soner Uşaklıc6b8256fffbb
diff --git a/public/src/modules/logout.js b/public/src/modules/logout.js
index 400d5c25e1..a44fb56cf0 100644
--- a/public/src/modules/logout.js
+++ b/public/src/modules/logout.js
@@ -1,6 +1,6 @@
'use strict';
-define('logout', ['hooks'], function (hooks) {
+define('logout', ['hooks', 'alerts'], function (hooks, alerts) {
return function logout(redirect) {
redirect = redirect === undefined ? true : redirect;
hooks.fire('action:app.logout');
@@ -23,6 +23,9 @@ define('logout', ['hooks'], function (hooks) {
}
}
},
+ error: function (jqXHR) {
+ alerts.error(String(jqXHR.responseText || '[[error:logout-error]]'));
+ },
});
};
});
diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js
index 007d3ba6ac..c946ca8292 100644
--- a/src/controllers/authentication.js
+++ b/src/controllers/authentication.js
@@ -459,7 +459,7 @@ authenticationController.localLogin = async function (req, username, password, n
}
};
-authenticationController.logout = async function (req, res, next) {
+authenticationController.logout = async function (req, res) {
if (!req.loggedIn || !req.sessionID) {
res.clearCookie(nconf.get('sessionKey'), meta.configs.cookie.get());
return res.status(200).send('not-logged-in');
@@ -475,21 +475,22 @@ authenticationController.logout = async function (req, res, next) {
await user.setUserField(uid, 'lastonline', Date.now() - (meta.config.onlineCutoff * 60000));
await db.sortedSetAdd('users:online', Date.now() - (meta.config.onlineCutoff * 60000), uid);
- await plugins.hooks.fire('static:user.loggedOut', { req: req, res: res, uid: uid, sessionID: sessionID });
+ await plugins.hooks.fire('static:user.loggedOut', { req, res, uid, sessionID });
// Force session check for all connected socket.io clients with the same session id
sockets.in(`sess_${sessionID}`).emit('checkSession', 0);
const payload = {
next: `${nconf.get('relative_path')}/`,
};
- plugins.hooks.fire('filter:user.logout', payload);
+ await plugins.hooks.fire('filter:user.logout', payload);
if (req.body.noscript === 'true') {
return res.redirect(payload.next);
}
res.status(200).send(payload);
} catch (err) {
- next(err);
+ winston.error(`${req.method} ${req.originalUrl}\n${err.stack}`);
+ res.status(500).send(err.message);
}
};