diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index dedb39358e4..ac6c8132f4a 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -629,7 +629,7 @@ class GroupsController < ApplicationController def find_group(param_name, ensure_can_see: true) name = params.require(param_name) group = Group.find_by("LOWER(name) = ?", name.downcase) - guardian.ensure_can_see!(group) if ensure_can_see + raise Discourse::NotFound if ensure_can_see && !guardian.can_see_group?(group) group end diff --git a/spec/requests/groups_controller_spec.rb b/spec/requests/groups_controller_spec.rb index f1a2b2d84ba..b122604f6c9 100644 --- a/spec/requests/groups_controller_spec.rb +++ b/spec/requests/groups_controller_spec.rb @@ -357,7 +357,7 @@ describe GroupsController do get "/groups/#{group.name}.json" - expect(response.status).to eq(403) + expect(response.status).to eq(404) end it "returns the right response" do @@ -430,7 +430,7 @@ describe GroupsController do get "/groups/#{group.name}/posts.json" - expect(response.status).to eq(403) + expect(response.status).to eq(404) end it "ensures the group members can be seen" do @@ -473,7 +473,7 @@ describe GroupsController do get "/groups/#{group.name}/members.json" - expect(response.status).to eq(403) + expect(response.status).to eq(404) end it "ensures the group members can be seen" do @@ -1888,7 +1888,7 @@ describe GroupsController do get "/groups/#{group.name}/permissions.json" - expect(response.status).to eq(403) + expect(response.status).to eq(404) end describe "with varying category permissions" do