Refactored auth controller.