2019-08-14 09:48:44 +00:00
|
|
|
class Api::BaseController < ApplicationController
|
2020-03-10 18:32:15 +00:00
|
|
|
include AccessTokenAuthHelper
|
2019-08-14 09:48:44 +00:00
|
|
|
respond_to :json
|
2020-03-10 18:32:15 +00:00
|
|
|
before_action :authenticate_access_token!, if: :authenticate_by_access_token?
|
|
|
|
before_action :validate_bot_access_token!, if: :authenticate_by_access_token?
|
|
|
|
before_action :authenticate_user!, unless: :authenticate_by_access_token?
|
2019-08-14 09:48:44 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
def authenticate_by_access_token?
|
2020-04-07 04:49:19 +00:00
|
|
|
request.headers[:api_access_token].present? || request.headers[:HTTP_API_ACCESS_TOKEN].present?
|
2020-03-10 18:32:15 +00:00
|
|
|
end
|
|
|
|
|
2019-08-14 09:48:44 +00:00
|
|
|
def set_conversation
|
|
|
|
@conversation ||= current_account.conversations.find_by(display_id: params[:conversation_id])
|
|
|
|
end
|
2020-02-17 02:21:45 +00:00
|
|
|
|
|
|
|
def check_billing_enabled
|
|
|
|
raise ActionController::RoutingError, 'Not Found' unless ENV['BILLING_ENABLED']
|
|
|
|
end
|
2019-08-14 09:48:44 +00:00
|
|
|
end
|