Route auth code refactoring