Skip to content

Node.js based forum software built for the modern web

fix crash

Barış Soner Uşaklı07572b188b6d
diff --git a/src/socket.io/index.js b/src/socket.io/index.js
index ba4f324d7c..337320e226 100644
--- a/src/socket.io/index.js
+++ b/src/socket.io/index.js
@@ -175,15 +175,17 @@ function authorize(socket, callback) {
cookieParser(handshake, {}, next);
},
function(next) {
- db.sessionStore.get(handshake.signedCookies['express.sid'], next);
- },
- function(sessionData, next) {
- if (sessionData && sessionData.passport && sessionData.passport.user) {
- socket.uid = parseInt(sessionData.passport.user, 10);
- } else {
- socket.uid = 0;
- }
- next();
+ db.sessionStore.get(handshake.signedCookies['express.sid'], function(err, sessionData) {
+ if (err) {
+ return next(err);
+ }
+ if (sessionData && sessionData.passport && sessionData.passport.user) {
+ socket.uid = parseInt(sessionData.passport.user, 10);
+ } else {
+ socket.uid = 0;
+ }
+ next();
+ });
}
], callback);
}