diff --git a/avni-server-api/src/main/java/org/avni/server/dao/UserRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/UserRepository.java index 9bb63d9df..45ad81d3c 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/UserRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/UserRepository.java @@ -104,15 +104,15 @@ default User getUser(String userId) { boolean hasPrivilege(String type, long userId); @Query(value = "select bool_or(groups.has_all_privileges) from users\n" + - " left outer join user_group ug on users.id = ug.user_id\n" + - " left outer join groups on ug.group_id = groups.id\n" + + " left outer join user_group ug on users.id = ug.user_id and ug.is_voided = false\n" + + " left outer join groups on ug.group_id = groups.id and groups.is_voided = false\n" + "where users.id = :userId", nativeQuery = true) Boolean hasAll(long userId); String BASE_ENTITY_TYPE_PRIVILEGE_QUERY = "select (count(p.id) > 0) as exists from group_privilege\n" + " join privilege p on group_privilege.privilege_id = p.id\n" + - " join groups on group_privilege.group_id = groups.id\n" + - " join user_group ug on groups.id = ug.group_id\n" + + " join groups on group_privilege.group_id = groups.id and groups.is_voided=false\n" + + " join user_group ug on groups.id = ug.group_id and ug.is_voided=false\n" + " join users on ug.user_id = users.id\n" + "where p.type = :type and users.id = :userId and group_privilege.allow";