-
-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/api/v2/users look up users by facility_id
and/or contact_id
#8877
Comments
One workaround would be to install a custom ddoc with a map/reduce view to facilitate this. Obviously the API is better but this would work on all versions of the CHT until the API is released. Something like... function (doc) {
if (doc.type === 'user-settings') {
if (doc.facility_id) emit('facility:' + doc.facility_id);
if (doc.contact_id) emit('contact:' + doc.contact_id);
}
} Use a bespoke ddoc so it doesn't get overwritten on upgrade. Then for the I think this will work but haven't actually tried it out yet... |
Sadly I don't think this will work above 4.4 because non-admin users can't send GET requests to the |
That's the beauty of this solution... the ddoc above is in the |
Yes true. Can use a {
"selector": {
"type": "user-settings",
"facility_id": facilityId,
"$or": [
{ "inactive": false },
{ "inactive": { "$exists": false } }
]
}
} It's a good suggestion. Curious what you think of this -- Hopefully the data in the
const myDoc = await CHTCore.DB.get().get('org.couchdb.user:malicious');
myDoc.facility_id = 'fake';
await CHTCore.DB.get().put(myDoc);
We have been trying not to rely on user-settings docs for any cht-user-management logic. But perhaps we should do it until this is resolved. |
Yes a find request will be easier to set up, but may not perform as well. Depending on your use case this might be fine! Yes you're right there is potential for a user to hide themselves with this approach. I'm now wondering why we allow users to modify their own user-settings doc at all. Other than their name I can't see anything in there that we should allow them to update so it should be in the @dianabarsan What do you think? Can we lock it down? If there is some optional field I'm forgetting we could at least lock down facility and contact updates. |
Unsure if user edits of user-settings contribute to #8337, but could lock down roles. |
I believe some things are stored on the user doc, for example:
If we block updates to this doc through validate_doc_update, we have to rethink how we do privacy policies at the least. My opinion is that users should not be allowed to edit their user doc, and everything should be done through APIs. With online first I know this is not possible. |
Issue raised: #8886 |
Additional APIs that would be useful for user management: https://github.com/medic/cht-user-management/blob/960bf86ca938460209e08498a789975763f6bc19/src/lib/cht-api.ts Adding here for tracking purposes not necessarily blocking the APIs requested in the description. |
facility_id
and/or contact_id
…8928) Co-authored-by: Joshua Kuestersteffen <[email protected]> Co-authored-by: Diana Barsan <[email protected]>
Is your feature request related to a problem? Please describe.
I want to look up the details for a single user by username
I want to look up the details for users with a specific facility_id or contact_id
Describe the solution you'd like
(Edit: split out retrieving data for a single user into #8986)GET /api/v2/users/username
GET /api/v2/users?facility_id=foo
GET /api/v2/users?contact_id=bar
Describe alternatives you've considered
Admin users (only) can query the database directly and use
/_users/_find
You can add
mm-online
role to the_users/_security
documentAdditional context
The text was updated successfully, but these errors were encountered: