From 99a1a28e01d4fbf7426d564a2a63031db9586744 Mon Sep 17 00:00:00 2001 From: Dmitrii Date: Wed, 23 Nov 2022 12:53:32 +0100 Subject: [PATCH] fix sql for anonymous user --- app/models/capabilities/scopes/default.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/app/models/capabilities/scopes/default.rb b/app/models/capabilities/scopes/default.rb index 76689cb2c2..2346c85f5d 100644 --- a/app/models/capabilities/scopes/default.rb +++ b/app/models/capabilities/scopes/default.rb @@ -46,7 +46,6 @@ module Capabilities::Scopes ) capabilities SQL - # binding.pry select('capabilities.*') .from(capabilities_sql) end @@ -130,15 +129,10 @@ module Capabilities::Scopes FROM (#{Action.default.to_sql}) actions JOIN "role_permissions" ON "role_permissions"."permission" = "actions"."permission" JOIN "roles" ON "roles".id = "role_permissions".role_id AND roles.builtin = #{Role::BUILTIN_ANONYMOUS} - JOIN (#{Principal.visible.not_builtin_without_anonymous.not_locked_without_anonymous.to_sql}) users - ON 1 = 1 + JOIN users ON users.type = '#{AnonymousUser.name}' JOIN "projects" ON "projects".active = true - AND ("projects".public = true OR EXISTS (SELECT 1 - FROM members - WHERE members.project_id = projects.id - AND members.user_id = users.id - LIMIT 1)) + AND "projects".public = true LEFT OUTER JOIN enabled_modules ON enabled_modules.project_id = projects.id AND actions.module = enabled_modules.name