Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

UserPermissibleService#allowed_globally did not return false when the user is locked

Klaus Zandersd4635c58c243
diff --git a/app/services/authorization/user_permissible_service.rb b/app/services/authorization/user_permissible_service.rb
index 1607f554d4c..134b5872a1a 100644
--- a/app/services/authorization/user_permissible_service.rb
+++ b/app/services/authorization/user_permissible_service.rb
@@ -8,6 +8,7 @@ module Authorization
def allowed_globally?(permission)
perms = contextual_permissions(permission, :global)
+ return false unless authorizable_user?
return true if admin_and_all_granted_to_admin?(perms)
cached_permissions(nil).intersect?(perms.map(&:name))
diff --git a/spec/services/authorization/user_permissible_service_spec.rb b/spec/services/authorization/user_permissible_service_spec.rb
index 4f97eec8bee..ea6ba6318bf 100644
--- a/spec/services/authorization/user_permissible_service_spec.rb
+++ b/spec/services/authorization/user_permissible_service_spec.rb
@@ -93,6 +93,12 @@ RSpec.describe Authorization::UserPermissibleService do
let!(:member) { create(:global_member, user:, roles: [global_role]) }
it { is_expected.to be_allowed_globally(permission) }
+
+ context 'and the account is locked' do
+ before { user.locked! }
+
+ it { is_expected.not_to be_allowed_globally(permission) }
+ end
end
end
@@ -100,6 +106,12 @@ RSpec.describe Authorization::UserPermissibleService do
let(:user) { create(:admin) }
it { is_expected.to be_allowed_globally(permission) }
+
+ context 'and the account is locked' do
+ before { user.locked! }
+
+ it { is_expected.not_to be_allowed_globally(permission) }
+ end
end
it_behaves_like 'the Authorization.roles scope used' do