Refactoring authorization controller