restructuring socket.io auth code