fix error

This commit is contained in:
rulingcom 2023-07-01 11:59:47 +08:00
parent 4717c3e78a
commit fb650c6c9c
2 changed files with 18 additions and 1 deletions

View File

@ -5,6 +5,7 @@ class Admin::BoxController < ApplicationController
Binary = File.expand_path("../../../../bin/box", __FILE__)
CSSFile = File.expand_path("../../../../white-on-black.css", __FILE__)
skip_before_action :verify_authenticity_token
before_action :check_login
def index
is_not_open = `fuser #{SocketFile}`.gsub(/\n/, '').empty?
@ -23,4 +24,12 @@ class Admin::BoxController < ApplicationController
reverse_proxy "unix://#{SocketFile}", path: path do |config|
end
end
private
def check_login
user = current_user
if user.nil? || user.is_admin?
return render :file => "#{Rails.root}/app/views/errors/404.html", :layout => false, :status => :not_found, :formats => [:html]
end
end
end

View File

@ -1,9 +1,11 @@
class Admin::PlowController < OrbitAdminController
class Admin::PlowController < ApplicationController
include ReverseProxy::Controller
SocketFile = "#{Rails.root}/tmp/plow.sock"
Binary = File.expand_path("../../../../bin/plow", __FILE__)
LogFile = "#{Rails.root}/tmp/plow_summary.log"
before_action :setup_setting, only: [:setting, :save_setting]
before_action :check_login
skip_before_action :verify_authenticity_token
def index
reverse_proxy "unix://#{Rails.root}/tmp/plow.sock", path: '/' do |config|
@ -56,6 +58,12 @@ class Admin::PlowController < OrbitAdminController
end
private
def check_login
user = current_user
if user.nil? || user.is_admin?
return render :file => "#{Rails.root}/app/views/errors/404.html", :layout => false, :status => :not_found, :formats => [:html]
end
end
def setup_setting
@setting = PlowSetting.first
@plow_pid = `fuser #{SocketFile}`.gsub(/\n/, '').to_i