Check user provider type in authorization expression

In the authorization expression of some function, I’d like to check that the user provider type is not anonymous. In plain javascript, that would be:

context.user.identities[0].provider_type != "anon-user"

How can I achieve the same thing in authorization expression? I don’t know how to access the first element of the array. I tried "%%user.identities.first.providerType"and "%%user.identities[0].providerType" but none of these works.

MongoDB team, any idea? Is that possible or not?

Hi Jean-Baptiste,

Please try using %%user.identities[0].provider_type

You could also make the expression call a function and within the function use context.user.identities[0].provider_type to return the value.