Fix bugs when inviting user via the api