Refactor auth to make it more readable and understandable.