mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: don't throw on invalid session, just return early so socket is not opened.
Also updated the plugin hook call to `static:sockets.validateSession` to not return a result, because in static calls that result is always null anyway
This commit is contained in:
@@ -89,9 +89,9 @@ async function onConnect(socket) {
|
||||
} catch (e) {
|
||||
if (e.message === '[[error:invalid-session]]') {
|
||||
socket.emit('event:invalid_session');
|
||||
return;
|
||||
}
|
||||
throw e;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (socket.uid) {
|
||||
@@ -208,12 +208,12 @@ async function validateSession(socket, errorMsg) {
|
||||
if (!sessionData) {
|
||||
throw new Error(errorMsg);
|
||||
}
|
||||
const result = await plugins.hooks.fire('static:sockets.validateSession', {
|
||||
|
||||
await plugins.hooks.fire('static:sockets.validateSession', {
|
||||
req: req,
|
||||
socket: socket,
|
||||
session: sessionData,
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
const cookieParserAsync = util.promisify((req, callback) => cookieParser(req, {}, err => callback(err)));
|
||||
|
||||
Reference in New Issue
Block a user