2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
2016-07-06 06:13:44 +00:00
|
|
|
|
|
|
|
class User
|
|
|
|
module SearchIndex
|
2018-04-26 08:55:53 +00:00
|
|
|
extend ActiveSupport::Concern
|
2016-07-06 06:13:44 +00:00
|
|
|
|
2021-01-27 09:58:35 +00:00
|
|
|
def search_index_attribute_lookup(include_references: true)
|
2017-09-11 00:50:05 +00:00
|
|
|
attributes = super
|
2021-01-27 09:58:35 +00:00
|
|
|
attributes.delete('password')
|
2017-09-11 00:50:05 +00:00
|
|
|
|
2021-01-27 09:58:35 +00:00
|
|
|
if include_references
|
|
|
|
attributes['permissions'] = []
|
|
|
|
permissions_with_child_ids.each do |permission_id|
|
|
|
|
permission = ::Permission.lookup(id: permission_id)
|
|
|
|
next if !permission
|
2016-07-06 06:13:44 +00:00
|
|
|
|
2021-01-27 09:58:35 +00:00
|
|
|
attributes['permissions'].push permission.name
|
2016-07-06 06:13:44 +00:00
|
|
|
end
|
2021-01-27 09:58:35 +00:00
|
|
|
attributes['role_ids'] = role_ids
|
2016-07-06 06:13:44 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
attributes
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|