feat: added new hook `static:sockets.validateSession` ()

* feat: added new hook

* fix: improper .bind() call, +req in static:sockets.validateSession

* fix: restored original sessionStore logic, +hook

original logic to retrieve the sessionStore was not faulty, but
was changed for the sake of changing things, which ultimately
led to issues with tests, etc.
v1.18.x
Julian Lam committed by GitHub
parent 6f1fb4eb24
commit 0263b4daec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,6 +10,7 @@ var cookieParser = require('cookie-parser')(nconf.get('secret'));
var db = require('../database');
var user = require('../user');
var logger = require('../logger');
var plugins = require('../plugins');
var ratelimit = require('../middleware/ratelimit');
@ -179,12 +180,17 @@ function validateSession(socket, callback) {
if (!req.signedCookies || !req.signedCookies[nconf.get('sessionKey')]) {
return callback();
}
db.sessionStore.get(req.signedCookies[nconf.get('sessionKey')], function (err, sessionData) {
if (err || !sessionData) {
return callback(err || new Error('[[error:invalid-session]]'));
}
callback();
plugins.fireHook('static:sockets.validateSession', {
req: req,
socket: socket,
session: sessionData,
}, callback);
});
}

Loading…
Cancel
Save