If this duplicates some of the logic from the authentication module, should this be moved there?