Refactor auth module