Class: Spree::Wing::BaseController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/spree/wing/base_controller.rb

Direct Known Subclasses

TransactionsController

Instance Method Summary collapse

Instance Method Details

#not_foundObject



24
25
26
# File 'app/controllers/spree/wing/base_controller.rb', line 24

def not_found
  render json: { response_code: 404, response_msg: I18n.t(:resource_not_found, scope: 'spree.api') }, status: 404
end

#wing_http_authenticate!Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/spree/wing/base_controller.rb', line 8

def wing_http_authenticate!
  wing_payment_method = Spree::PaymentMethod.find_by(type: Spree::PaymentMethod::TYPE_WINGSDK)

  authenticate_or_request_with_http_basic do |username, password|
    return false unless wing_payment_method.present?

    if wing_payment_method.preferred_basic_auth_username.blank? ||
       wing_payment_method.preferred_basic_auth_password.blank?
      return false
    end

    username == wing_payment_method.preferred_basic_auth_username &&
      password == wing_payment_method.preferred_basic_auth_password
  end
end