mirror of
https://0xacab.org/sutty/sutty
synced 2025-02-22 22:11:50 +00:00
28 lines
693 B
Ruby
28 lines
693 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Api
|
|
module V1
|
|
# API para sitios
|
|
class SitesController < BaseController
|
|
http_basic_authenticate_with name: ENV['HTTP_BASIC_USER'],
|
|
password: ENV['HTTP_BASIC_PASSWORD']
|
|
|
|
def index
|
|
render json: Site.all.order(:name).pluck(:name) +
|
|
DeployAlternativeDomain.all.map(&:hostname)
|
|
end
|
|
|
|
# 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
|