Refactor auth code to be in auth.js, AJAX code in ajax.js