Delete Anonymous Provider from User

I’m looking for a way to programmatically remove a user’s anonymous provider from its list of providers, maybe from within a Function.

I don’t see a way to manipulate users other than registering or linking. Here’s the use case:

  1. A new user is signed in automatically as an anonymous user and can use the app (one anonymous user is added to the app).
  2. They later register with email & password, and the account is linked (the anonymous user is provided with an email, and now has 2 providers: email & anonymous).
  3. The user signs out.
  4. Later, they come back to the app and start using it with a new anonymous user (two users in the app: one anonymous, and one combined email & anonymous).
  5. They later sign in with their registered email & password. We cannot link the new anonymous account to their existing account because it already has a linked anonymous account (and now we have two users in the app, but the anonymous user is orphaned).

To avoid the orphaned anonymous user, I’m thinking we can delete the anonymous identity from the user as soon as they link their account since it’s no longer needed. Then, when they log in again, we can link the new anonymous account because the registered account doesn’t have an anonymous provider.

Is there any way to manage a user’s list of providers in Realm?