DEV: Only return users with a non-negative ID

This commit is contained in:
Peter Bouda 2024-10-25 10:00:50 +01:00
parent b93a0ae663
commit 5f590e1c54
2 changed files with 5 additions and 5 deletions

View file

@ -25,7 +25,7 @@ module Scim
end end
def storage_scope def storage_scope
User.all User.where("id >= ?", 0)
end end
end end
end end

View file

@ -12,8 +12,8 @@ module DiscourseScim::GroupMixin
{ {
id: :id, id: :id,
displayName: :name, displayName: :name,
members: [ # NB read-write, though individual items' attributes are immutable members: [
list: :scim_users_and_groups, # See adapter accessors, earlier in this file list: :scim_users_and_groups,
using: { using: {
value: :id value: :id
}, },
@ -46,11 +46,11 @@ module DiscourseScim::GroupMixin
end end
def scim_users_and_groups 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 end
def scim_users_and_groups=(mixed_array) 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) } self.associated_groups = mixed_array.select { |item| item.is_a?(Group) }
end end