refactor: support 2.42 en userRepository and UserModel#342
refactor: support 2.42 en userRepository and UserModel#342adrianq merged 6 commits intodevelopmentfrom
Conversation
|
As discussed with @xurxodev we will remove the 2FA filter for 42 from the graphical interface. I have also created a task to eventually take care of the refactor: https://app.clickup.com/t/869ctkw05 |
BundleMonNo change in files bundle size Groups updated (1)
Final result: ✅ View report in BundleMon website ➡️ |
|
@adrianq Ready remove 2FA from filter and also from columns |
|
Smoke-tested this against play.im.dhis2.org/stable-2-42-4 and the 2.42 routing works end-to-end — filters use root-level disabled / externalAuth / userRoles.id, the 2FA column/filter are correctly hidden, and saves succeed. One thing worth checking before merge: on 2.42 the save payload (and the list fields= query) still include the full userCredentials.* block alongside the new root-level fields — it's a dual-write, not a version-split. Concretely, on a 2.42.4 save I see: @xurxodev Two questions: Is the duplication intentional (belt-and-braces for backward compat across versions)? If so, a one-line comment near the version-detection helper would go a long way. Full test listBoot & shell Users list Filters Edit user (target: traore, UID oXD88WWSQpR) Create user (API path, 6a) Create user (UI form path, 6b) Copy in user (target: smoke_1776338902) Bulk edit (targets: smoke user + traore) User Roles page User Groups page CSV export Import/Export menu (Users tab) Dashboards tab Settings modal OU assignment modals (target: traore) 2FA user edit — N/A Cleanup Other Manual tests✅ Create user through file import |
…read - The shouldSendTwoFA guard in buildUsersToSave was effectively dead code: the `...user.userCredentials` spread already injected twoFA (including false) into the payload, which could disable 2FA on save. Strip twoFA from the spread so the guard actually controls the field. - Also expand the dual-write comment to document that root-level fields are required by DHIS2 2.42+ (where userCredentials was removed) while the userCredentials block is kept for ≤2.41 compatibility.
|
Thanks @MiquelAdell for the testing Answering your two questions:
Pushed a fix that:
Payload on 2.42 should now be clean of |
|
Re-ran the smoke test against 639f3a7 on play.im.dhis2.org/stable-2-42-4. The save payload is now clean: twoFA absent from both root and userCredentials, all other root-level fields intact, save returns 200 with updated:1. 👍 |
📌 References
📝 Implementation
Tab users
Refactor detected
@Ramon-Jimenez @adrianq I've detected a posible refactor in this app.
From use cases and components for filters, this code builds expressions like userCredentials.username:in:[].
The problem is that userCredentials no longer exists in version 2.42. The changes required to adapt to 2.42 should only affect the data layer.
The main issue is that there is currently a coupling between the app and DHIS2 filters. The domain, presentation and data layers are using DHIS2 filters directly. The domain should have its own filter model and adapt to and from DHIS2 filters within the repository.
To avoid a large refactor in this PR, I fixed it by using a replace function based on the version in the repository. However, this solution may be insufficient if future API versions introduce similar changes.
I think a refactor in this area is necessary.
Questions for PMs
Previously the user filters to filter by 2factor enabled the code used userCredentials.twoFA.
In 2.42 userCredentials is not in the response and twoFA has not been included in user.
Now if the version is 2.42 the filter has not effect because is removed in the process to avoid fail in api request.
📹 Screenshots/Screen capture
🔥 Testing