5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-23 05:26:22 +00:00
panel/app/controllers/api/v1/base_controller.rb

37 lines
858 B
Ruby
Raw Permalink Normal View History

2019-09-05 18:56:24 +00:00
# frozen_string_literal: true
module Api
module V1
# API
class BaseController < ActionController::Base
2020-08-29 23:21:45 +00:00
include ExceptionHandler
2019-09-05 18:56:24 +00:00
protect_from_forgery with: :null_session
2019-09-06 23:40:33 +00:00
respond_to :json
2020-03-23 20:46:19 +00:00
private
2020-05-30 19:43:25 +00:00
# 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
2020-03-23 20:46:19 +00:00
def origin
request.headers['Origin']
end
2020-09-28 21:46:55 +00:00
# Los navegadores antiguos no envían Origin
def origin?
!origin.blank?
end
2019-09-05 18:56:24 +00:00
end
end
end