5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-06-29 22:46:07 +00:00
panel/app/controllers/api/v1/base_controller.rb

37 lines
858 B
Ruby

# frozen_string_literal: true
module Api
module V1
# API
class BaseController < ActionController::Base
include ExceptionHandler
protect_from_forgery with: :null_session
respond_to :json
private
# Realiza la inversa de Site#hostname
#
# TODO: El sitio sutty.nl no aplica a ninguno de estos y le
# tuvimos que poner 'sutty.nl..sutty.nl' para pasar el test.
def site_id
@site_id ||= if params[:site_id].end_with? Site.domain
params[:site_id].sub(/\.#{Site.domain}\z/, '')
else
params[:site_id] + '.'
end
end
def origin
request.headers['Origin']
end
# Los navegadores antiguos no envían Origin
def origin?
!origin.blank?
end
end
end
end