Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Simplify the generation of a secret key by depending on Rails' has_secure_token
Stefan Vermaas8e31721f01f6
diff --git a/api/app/models/spree/webhooks/subscriber.rb b/api/app/models/spree/webhooks/subscriber.rbindex 0e443270cc..7b681e1353 100644--- a/api/app/models/spree/webhooks/subscriber.rb+++ b/api/app/models/spree/webhooks/subscriber.rb@@ -5,11 +5,11 @@ module Spreeinclude Spree::VendorConcernend+ has_secure_token :secret_key+has_many :events, inverse_of: :subscribervalidates :url, 'spree/url': true, presence: true- validates :secret_key, presence: true-validate :check_uri_pathself.whitelisted_ransackable_attributes = %w[active subscriptions url]@@ -18,7 +18,6 @@ module Spreescope :active, -> { where(active: true) }scope :inactive, -> { where(active: false) }- before_validation :generate_secret_key, unless: :secret_key?before_save :parse_subscriptionsdef self.with_urls_for(event)@@ -53,10 +52,6 @@ module Spreeerrors.add(:url, 'the URL must have a path') if uri.blank? || uri.path.blank?end- def generate_secret_key- self.secret_key = SecureRandom.urlsafe_base64(32)- end-def parse_subscriptionsreturn if subscriptions.blank? || subscriptions.is_a?(Array)