From 5f590e1c54d9a90493aaefdde4a0d2820f089753 Mon Sep 17 00:00:00 2001 From: Peter Bouda Date: Fri, 25 Oct 2024 10:00:50 +0100 Subject: [PATCH] DEV: Only return users with a non-negative ID --- app/controllers/scim_v2/users_controller.rb | 2 +- lib/discourse_scim/group_mixin.rb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/scim_v2/users_controller.rb b/app/controllers/scim_v2/users_controller.rb index 6dab273..5096e6b 100644 --- a/app/controllers/scim_v2/users_controller.rb +++ b/app/controllers/scim_v2/users_controller.rb @@ -25,7 +25,7 @@ module Scim end def storage_scope - User.all + User.where("id >= ?", 0) end end end \ No newline at end of file diff --git a/lib/discourse_scim/group_mixin.rb b/lib/discourse_scim/group_mixin.rb index ce0ec1a..1a5a2d9 100644 --- a/lib/discourse_scim/group_mixin.rb +++ b/lib/discourse_scim/group_mixin.rb @@ -12,8 +12,8 @@ module DiscourseScim::GroupMixin { id: :id, displayName: :name, - members: [ # NB read-write, though individual items' attributes are immutable - list: :scim_users_and_groups, # See adapter accessors, earlier in this file + members: [ + list: :scim_users_and_groups, using: { value: :id }, @@ -46,11 +46,11 @@ module DiscourseScim::GroupMixin end def scim_users_and_groups - self.users.to_a + self.associated_groups.to_a + self.users.select{ |item| item.id >= 0 }.to_a + self.associated_groups.to_a end def scim_users_and_groups=(mixed_array) - self.users = mixed_array.select { |item| item.is_a?(User) } + self.users = mixed_array.select { |item| item.is_a?(User) && item.id >=0 } self.associated_groups = mixed_array.select { |item| item.is_a?(Group) } end