SORMAS-Project
SORMAS-Project copied to clipboard
Make user sync more resilient to missing user roles
Problem Description
#9903 showed that users without user roles make data sync breaking.
UserDtoHelper.fillInnerFromDto
is to complicated (imho):
- Fiddles around with userroles if not empty. This helps to avoid currupting existing data (makes data different to server then!), but the initial sync
- Calculates
JurisdictionLevel
despite being sent in the DTO, that fails ifuserRoles == null
.
Proposed Change
Make data sync work even if users don't have user roles.
- [ ] Do a null-check for source.getUserRoles() when using source.getUserRoles().size()
- [ ] in UserDtoHelper.fillInnerFromDto set the jurisdiction level to the value of the UserDto, instead of re-calculating it (this was needed back in the times when the UserDto did not have a jurisdiction level
Acceptance Criteria
- When the user role(s) of a user are changed, this is properly synced to the mobile device
- When the jurisdiction level of a user is changed, this is properly synced to the mobile device
I have added details and acceptance criteria.
We saw with @sergiupacurariu that right now this scenario ( editing or creating a user without a user role) is not possible from the Sormas UI, because the user roles are mandatory:
I'll check if the API is exposed in the Resource ( if the user roles can be changed from Postman or the Automation tests). This would be a possible scenario for having users without user roles.
I've checked the code and the endpoints related to the user's role ( or edititing / creating) are not exposed which means that currently there is no way to create/update a user without user roles ( from Sormas Ui or from Postman/Automation tests).
Probably was possible before the user roles became mandatory in Sormas UI.
Verified ticket on the local machine using the latest version of SORMAS from the development branch - 1.91.0-SNAPSHOT(3a8bfa5).
The mobile app is updated based on the user's rights and/or roles by doing the following steps: I - if already logged with the user in the mobile app
- In the web app, log in with an Admin+NatUser;
- Navigate to the 'Users' directory and open an existing user;
- Edit them by changing the user role and save(update the user that is already logged in the mobile app);
- With the user that's already logged in the mobile app trigger a re-synchronize data;
- Log out and then log in with the same user;
- Observe the display of the mobile app (what entities the user has access to based on the role given).
II - if logged with other user in the mobile app
- In the web app, log in with an Admin+NatUser;
- Navigate to the 'Users' directory and open an existing user;
- Edit them by changing the user role and save;
- With the user that's already logged in the mobile app trigger a re-synchronize data;
- Log out and then log in with the user updated at step 3;
- Observe the display of the mobile app (what entities the user has access to based on the role given).
III - if mobile app is not started:
- In the web app, log in with an Admin+NatUser;
- Navigate to the 'Users' directory and open an existing user;
- Edit them by changing the user role and save;
- Start the mobile app and log in with the updated user from step 3.
- Observe the display of the mobile app (what entities the user has access to based on the role given).
Additionally, for the scenarios, at step 3, the user rights of the role already assigned to the user can be updated and the flow would work the same afterwards.