Add ensureAuthenticated on all the apis
Minor Refactoring in web.js