Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Webhook for bulk updating accounts usergroup (#264)
Implements the endpoint `PUT /api/v2/webhooks/accounts/user-group`, allowing an external service to update user groups in bulk. Example request body: ``` { "privilegedUsers": [ { "accountId": 123, "userGroup": "Manager" }, { "accountId": 124, "userGroup": "Barista" } ] } ``` The X-Api-Key header should be present on the request with a valid API key. The userGroup should be one of: - Barista - Manager - Board - (Customer will also work, but will have the same effect as not specifying the user in the request) ### Notes on testing I have been unable to implement an integration test, since EFCore.InMemory does not seem to support the performance-optimized ExecuteUpdate that is implemented in EF Core 7 and used in this service. Reference: https://stackoverflow.com/questions/74907256/ef-7-new-executedelete-and-executeupdate-methods-not-working-on-an-in-memory-d ### Business logic Initially, business logic was implemented using client-side hashing to verify duplicate requests did not use many resources. Later, it was changed to server-side hashing however hashing was completely removed again, as it would cause weird behaviour in combination with the below mentioned existing endpoint. Now it will be clearer that the state in the external system will correct itself if analog-core and the external system are out of sync. ### Notes on affected existing endpoints This change will also mark our `PATCH /api/v2/account/<id>/user-group` endpoint, as any calls to the new endpoint will override any user-groups set by the old patch endpoint. The endpoint is used by the Shifty User Manager from AnalogIO/shifty-webapp#21 --------- Co-authored-by: Jonas Anker Rasmussen <[email protected]>
- Loading branch information