Extract user authentication to a module