Passport.socketio - 2 users connect for every 1 connection

Passport.socketio - 2 users connect for every 1 connection
0

Full code: https://glitch.com/edit/#!/fcc-socketio-auth

I implemented the option to pass ‘success’ and ‘fail’ with a function that’s called after the authentication process completes when a client tries to connect.

But now my browser console log 'user count' is incremented twice for each time I connect via the ‘Login with Github’ link.

When passportSocketIo reads the user cookie and runs either onAuthorizeSuccess or onAuthorizeFail is that registered as a connection (user) also?

// Authentication with Socket.IO
  	io.use(passportSocketIo.authorize({
      cookieParser: cookieParser,
      key:          'express.sid',
      secret:       process.env.SESSION_SECRET,
      store:        sessionStore,
      success:      onAuthorizeSuccess,   
      fail:         onAuthorizeFail,  
    }));
  
// listening for connections
    var currentUsers = 0;  
    io.on('connection', socket => {
      console.log('A user has connected');
      ++currentUsers;
      io.emit('user count', currentUsers);
      console.log('user ' + socket.request.user.name + ' connected');
      
      socket.on('disconnect', () => { 
        console.log('a user has disconnected');
        --currentUsers;
        io.emit('user count', currentUsers);  
      });
       
    });