Code refactoring by creating an authentication controller.