Guest User

Untitled

a guest
Dec 6th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1.  
  2. io.configure(function() {
  3.  
  4. io.set('authorization', function(handshakeData, callback) {
  5.  
  6. if (handshakeData.headers.cookie) {
  7.  
  8. req_cookie = cookie.parse(decodeURIComponent(handshakeData.headers.cookie));
  9.  
  10. req_session = parseSignedCookie(req_cookie['connect.sid'], SECRET);
  11.  
  12. sessionStore.get(req_cookie['connect.sid'], function(err, session) {
  13.  
  14. if (session) {
  15.  
  16. req = {
  17. sessionStore: sessionStore,
  18. sessionID: handshakeData.sessionID
  19. };
  20.  
  21. session = new express.session.Session(req, session);
  22. console.log(JSON.stringify(session));
  23. //handshakeData.session = new Session(handshakeData, session);
  24. }
  25. if (err || !session) {
  26. console.log(JSON.stringify(session));
  27. console.log(JSON.stringify(err));
  28. console.log( 'Error!!!');
  29. return callback(err, false);
  30. }
  31. else {
  32.  
  33. handshakeData.session = new Session(data, session);
  34. return callback(null, true);
  35. }
  36.  
  37. });
  38. } else {
  39.  
  40. return callback('No cookie transmitted', false);
  41. }
  42. });
  43. });
Add Comment
Please, Sign In to add comment