Refactored auth controller