Commit ad7450dd authored by HERBERT Ryan's avatar HERBERT Ryan
Browse files

tests/VidjilAuth fixed a bug where accessible_query would not return any...

tests/VidjilAuth fixed a bug where accessible_query would not return any values if there were no group associations
parent dd4a0243
...@@ -443,15 +443,19 @@ class VidjilAuth(Auth): ...@@ -443,15 +443,19 @@ class VidjilAuth(Auth):
membership = self.table_membership() membership = self.table_membership()
permission = self.table_permission() permission = self.table_permission()
perm_groups = self.get_permission_groups(name, table, user_id) perm_groups = self.get_permission_groups(name, table, user_id)
query = table.id.belongs( query = (table.id.belongs(
db(membership.user_id == user_id) db(((membership.user_id == user_id) &
(membership.group_id.belongs(perm_groups)) (membership.group_id.belongs(perm_groups)) &
((membership.group_id == permission.group_id) | (membership.group_id == permission.group_id) &
((membership.group_id == db.group_assoc.second_group_id) & (permission.name == PermissionEnum.access.value) &
(db.group_assoc.first_group_id == permission.group_id))) (permission.table_name == table)))._select(permission.record_id)) |
(permission.name == PermissionEnum.access.value) table.id.belongs(
(permission.table_name == table) db(((membership.user_id == user_id) &
._select(permission.record_id)) (membership.group_id.belongs(perm_groups)) &
(membership.group_id == db.group_assoc.second_group_id) &
(db.group_assoc.first_group_id == permission.group_id) &
(permission.name == PermissionEnum.access.value) &
(permission.table_name == table)))._select(permission.record_id)))
if self.settings.everybody_group_id: if self.settings.everybody_group_id:
query |= table.id.belongs( query |= table.id.belongs(
db(permission.group_id == self.settings.everybody_group_id) db(permission.group_id == self.settings.everybody_group_id)
......
Supports Markdown
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