Class: Api::Vendor::V1::Pointx::BaseController

Inherits:
ApplicationController show all
Includes:
ElasticAPM::SpanHelpers
Defined in:
app/controllers/api/vendor/v1/pointx/base_controller.rb

Direct Known Subclasses

ConversionRateController

Instance Method Summary collapse

Methods inherited from ApplicationController

#after_sign_in_path_for, #after_sign_out_path_for, #default_url_options, #render_not_found, #routing_error, search_params_key=

Methods included from LogrageCustomLogger

#append_info_to_payload

Methods included from ControllerHelpers

#check_boolean_param, #get_banners, #inventory_params, #reservation_params

Instance Method Details

#authenticate!Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/api/vendor/v1/pointx/base_controller.rb', line 12

def authenticate!
  token = request.headers['vendor-webview-integration-token']
  if token.present?
    doorkeeper_app = find_webview_doorkeeper_app
    raise 'Webview integration app not found' if doorkeeper_app.blank?
    raise 'Invalid authentication token' if token != doorkeeper_app.uid

    true
  else
    raise 'missing authentication header'
  end
rescue StandardError => e
  APMErrorHandler.report(
    "PointX: #{e.message}",
    context: {
      provided_token: token,
      ip: request.remote_ip,
      request: request,
    },
  )

  render json: { error: 'Sorry, Something went wrong' }, status: :unauthorized
end

#identity_cache_memoization(&block) ⇒ Object



37
38
39
# File 'app/controllers/api/vendor/v1/pointx/base_controller.rb', line 37

def identity_cache_memoization(&block)
  IdentityCache.cache.with_memoization(&block)
end