moved authentication logic to site.js file