refactored authentication.js and user