DEV: Allow plugins to mark user custom fields as editable only by staff

This adds a staff_only parameter to the register_editable_user_custom_field API. The default is false, to maintain backwards compatibility.
This commit is contained in:
David Taylor
2019-10-11 09:57:55 +01:00
parent 3bcfa158a7
commit 67787799bb
4 changed files with 40 additions and 9 deletions

View File

@ -1425,7 +1425,8 @@ class UsersController < ApplicationController
:card_background_upload_url
]
permitted << { custom_fields: User.editable_user_custom_fields } unless User.editable_user_custom_fields.blank?
editable_custom_fields = User.editable_user_custom_fields(by_staff: current_user.try(:staff?))
permitted << { custom_fields: editable_custom_fields } unless editable_custom_fields.blank?
permitted.concat UserUpdater::OPTION_ATTR
permitted.concat UserUpdater::CATEGORY_IDS.keys.map { |k| { k => [] } }
permitted.concat UserUpdater::TAG_NAMES.keys