Node.js: Authentication module implementation, fixes to server login