refactored user authentication stuff