Refactoring auth api.