Files
openfoodnetwork/app/services/permitted_attributes/user.rb
David Cook 00a823b2fc 6. Add webhook endpoints to user developer settings screen
Allowing creation and deleting via the user association.
It probably won't be much effort to allow editing and multiple records, but I cut it down to the minimum needed to avoid any further delays.

I couldn't find a way to test a failure in the destroy method, but decided to keep the condition because I thought it was worth having.
2023-03-07 15:38:50 +11:00

25 lines
543 B
Ruby

# frozen_string_literal: true
module PermittedAttributes
class User
def initialize(params, resource_name = :user)
@params = params
@resource_name = resource_name
end
def call(extra_permitted_attributes = [])
@params.require(@resource_name).
permit(permitted_attributes + extra_permitted_attributes)
end
private
def permitted_attributes
[
:email, :password, :password_confirmation, :disabled,
{ webhook_endpoints_attributes: [:id, :url] },
]
end
end
end