Sha256: ce06a77d93ac22801687a1ed96fe2ceafcb85151b738b8264b143a556b4e1b30

Contents?: true

Size: 428 Bytes

Versions: 3

Compression:

Stored size: 428 Bytes

Contents

require_dependency 'spree/base_controller'

Spree::BaseController.class_eval do
  before_filter :ensure_api_key

  # Need to generate an API key for a user due to some actions potentially
  # requiring authentication to the Spree API
  def ensure_api_key
    if user = try_spree_current_user
      if user.respond_to?(:spree_api_key) && user.spree_api_key.blank?
        user.generate_spree_api_key!
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spree_api-1.3.5 app/controllers/spree/base_controller_decorator.rb
spree_api-1.3.4 app/controllers/spree/base_controller_decorator.rb
spree_api-1.3.3 app/controllers/spree/base_controller_decorator.rb