Replace mcrcon command with system command

This commit is contained in:
conor 2019-10-21 11:05:59 +02:00
parent e8fb72653d
commit 7eca69b4a6

View file

@ -5,7 +5,7 @@ class VouchersController < ApplicationController
# GET /vouchers
def index
@vouchers = Voucher.all
whitelist = %x{mcrcon -c -H mine.vereto.net -p #{ENV["MC_RCON_PASS"]} 'whitelist list' | sed 's/There are*.*whitelisted players: //g'}.gsub("\n", "")
whitelist = %x{mc-whitelist-users}.gsub("\n", "")
render json: { :vouchers => @vouchers, :whitelist => whitelist }.to_json
end
@ -19,7 +19,7 @@ class VouchersController < ApplicationController
def create
# Logic for creating a voucher
output = ""
whitelist = %x(mcrcon -c -H mine.vereto.net -p #{ENV["MC_RCON_PASS"]} "whitelist list" | sed 's/There are*.*whitelisted players: //g').gsub("\n", "").split(", ")
whitelist = %x(mc-whitelist-users).gsub("\n", "").split(", ")
if Voucher.exists?(vouchee: params[:voucher]) && params[:voucher].in?(whitelist)
@voucher = Voucher.new(voucher_params)