Bug report: auth.findUsers, searching via key fails but _id works


#1

Enonic version: 7.2
OS: Mac OS Catalina

When using auth.findUsers (authentication library) and wanting to use/search for a certain ‘key’ in query, then I end up with 0 results. On the other hand, using ‘_id’ does work.

This does not work
const author = findUsers({
count: 1,
query: key = '${creator}'
});

This does work
const author = findUsers({
count: 1,
query: _id = '${creator}'
});

The issue here is that the structure for each result does not contain ‘_id’ but ‘key’ (following example taken from xp documentation):
type: “user”,
key: “user:system:jorgen-juve”,
displayName: “Jørgen Juve”,
disabled: false,
email: "[email protected]",
login: “jorgen-juve”,
idProvider: “system”

Best regards,
BetaKeks


#2

Hi @BetaKeks. Thank you for reporting this, looks like a bug. We’ll investigate and get back to you.


#3

We do have some inconsistency here. API operates with key field, while ElasticSearch expects _id, hence the problem. We’ve registered an issue and discuss how/if we will solve this. Have also updated documentation for findUsers to mention the case of finding users by key.