2019-09-05 18:56:24 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Api
|
|
|
|
module V1
|
|
|
|
# API para sitios
|
|
|
|
class SitesController < BaseController
|
2020-02-06 16:11:17 +00:00
|
|
|
http_basic_authenticate_with name: ENV['HTTP_BASIC_USER'],
|
|
|
|
password: ENV['HTTP_BASIC_PASSWORD']
|
|
|
|
|
2019-09-06 23:40:33 +00:00
|
|
|
def index
|
|
|
|
render json: Site.all.order(:name).pluck(:name)
|
|
|
|
end
|
|
|
|
|
2019-09-05 18:56:24 +00:00
|
|
|
# Detecta si se puede generar un certificado
|
|
|
|
def allowed
|
|
|
|
name = params[:domain].gsub(/\.#{Site.domain}\Z/, '')
|
|
|
|
site = Site.find_by(name: name)
|
|
|
|
|
|
|
|
if site
|
|
|
|
head :ok
|
|
|
|
else
|
|
|
|
head :not_found
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|