Module: SpreeCmCommissioner::WaitingRoomAuthorization

Extended by:
ActiveSupport::Concern
Defined in:
app/controllers/concerns/spree_cm_commissioner/waiting_room_authorization.rb

Instance Method Summary collapse

Instance Method Details

#ensure_waiting_room_session_tokenObject



13
14
15
16
17
18
19
# File 'app/controllers/concerns/spree_cm_commissioner/waiting_room_authorization.rb', line 13

def ensure_waiting_room_session_token
  return if ENV['WAITING_ROOM_DISABLED'] == 'yes'
  return if request_from_client?
  return unless required_waiting_room_session?

  JWT.decode(params[:waiting_room_session_token], ENV.fetch('WAITING_ROOM_SESSION_SIGNATURE', nil), true, { algorithm: 'HS256' })
end

#handle_waiting_room_session_token_errorObject



33
34
35
# File 'app/controllers/concerns/spree_cm_commissioner/waiting_room_authorization.rb', line 33

def handle_waiting_room_session_token_error
  render_error_payload(Spree.t(:invalid_session_token), 400)
end

#request_from_client?Boolean

temporary disable session check from any client server requests.

Returns:

  • (Boolean)


29
30
31
# File 'app/controllers/concerns/spree_cm_commissioner/waiting_room_authorization.rb', line 29

def request_from_client?
  request.headers['X-Cm-Api-Client-Version'].present?
end

#required_waiting_room_session?Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
# File 'app/controllers/concerns/spree_cm_commissioner/waiting_room_authorization.rb', line 21

def required_waiting_room_session?
  # temporary disable
  apis = []

  apis.any? { |prefix| request.path.start_with?(prefix) }
end