move authentication code to authenticationManager.js