If a user is logged in with anonymous credentials so that they can access some realm sync data, but they have not yet authenticated with an identity provided by any other means (i.e. email/password, “local-pass”), how would you check to see if they have an identity provider other than anonymous?
So far the best I can do is check the RLMUser.identities array of strings to see. Is there a better way?
So my question to this, is are you using the OAuth? Because a really easy way to situate something like user authentication would be the built in OAUTH capabilities such as JWT, Google, Facebook, and so on.
I plan to use several of the providers in the future, but for now I’m speaking specifically about the RLMUser object that is held in RealmSwift.App.currentUser on the iOS client.
I’m using it as my source of truth for the app’s authentication state. The problem I have is that - because I support anonymous users - I need a way to tell if the currentUser was gotten by .anonymous credentials or .emailPassword (or others). So in other words, a strategy that goes beyond checking if currentUser == nil
You can also self-populate this value in custom user data when the user first registers by using an authentication trigger, but the user.data.identities field in the user object should also have what you’re looking for.