Commit 08264cba authored by RANNOU's avatar RANNOU 👽
Browse files

[enh] Service: filter trips by department (#392)

parent 80c01fe3
......@@ -1395,16 +1395,19 @@ public class DataGraphQLService {
protected TripFilterVO fillTripFilterDefaults(TripFilterVO filter) {
TripFilterVO result = filter != null ? filter : new TripFilterVO();
// Restrict to self data - issue #199
if (!canAccessNotSelfData()) {
PersonVO user = authService.getAuthenticatedUser().orElse(null);
if (user != null) {
result.setRecorderDepartmentId(null);
// Restrict to self data and/or department data
PersonVO user = authService.getAuthenticatedUser().orElse(null);
if (user != null) {
if (!canAccessNotSelfData()) {
result.setRecorderPersonId(user.getId());
} else {
result.setRecorderPersonId(-999); // Hide all. Should never occur
}
if (!canAccessNotSelfDepartmentData(user)) {
result.setRecorderDepartmentId(user.getDepartment().getId());
}
} else {
result.setRecorderPersonId(-999); // Hide all. Should never occur
}
return result;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment