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
|
|
|
end
|