Skip to content

Commit

Permalink
Merge pull request #17 from opentechinstitute/input-validation
Browse files Browse the repository at this point in the history
Fixed validation error in bigboard config form. Tested by @jheretic, with additional module import fix works fine.
  • Loading branch information
jheretic committed Mar 6, 2014
2 parents 064c93b + edd59f5 commit 8d38200
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions luasrc/controller/commotion-dash/bigboard-conf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ module("luci.controller.commotion-dash.bigboard-conf", package.seeall)
require "luci.model.uci"
require "luci.fs"
require "luci.sys"
local log = require "luci.commotion.debugger".log

local dashConfig = "/etc/config/commotion-dash"

function index()
local debug = require "luci.commotion.debugger"
require("luci.i18n").loadc("commotion")
local i18n = luci.i18n.translate
local uci = luci.model.uci.cursor()
Expand All @@ -41,7 +41,7 @@ function index()
entry({"admin", "status", "bigboard-conf_submit"}, call("ifprocess"))
entry({"admin", "status", "bigboard-conf"}, call("main"), translate("BigBoard Configuration"), 20).dependent=false
else
debug.log("Can't run Commotion-Dashboard. Install olsrd jsoninfo plugin.")
log("Can't run Commotion-Dashboard. Install olsrd jsoninfo plugin.")
end
end
end
Expand All @@ -68,7 +68,6 @@ config dashboard
end

function ifprocess()
local debug = require "luci.commotion.debugger"
local values = luci.http.formvalue()
local encode = require "luci.commotion.encode"
local dt = require "luci.cbi.datatypes"
Expand All @@ -80,15 +79,15 @@ function ifprocess()

if values['bbOnOff'] ~= nil then
--[[ validate destination address ]]--
if dt.host(values['gatherer_ip']) == true then
if dt.host(values['gatherer_ip']) ~= true then
ERR = 'ERROR: invalid IP or site address ' .. values['gatherer_ip']
debug.log("Error validating inputs " .. values['gatherer_ip'])
log("Error validating inputs " .. values['gatherer_ip'])
main(ERR)
do return end
end

debug.log("Commotion-Dashboard: Enabling network stats submission...")
debug.log("Commotion-Dashboard: Setting " .. values['gatherer_ip'] .. "as network stats collector")
log("Commotion-Dashboard: Enabling network stats submission...")
log("Commotion-Dashboard: Setting " .. values['gatherer_ip'] .. "as network stats collector")
if ERR == nil then
local uci = luci.model.uci.cursor()
uci:set("commotion-dash", values['dashName'], "enabled", values['bbOnOff'])
Expand All @@ -97,7 +96,7 @@ function ifprocess()
uci:save('commotion-dash')
end
else
debug.log("Disabling Commotion-Dashboard")
log("Disabling Commotion-Dashboard")
local uci = luci.model.uci.cursor()
uci:set("commotion-dash", values["dashName"], 'enabled', 'false')
uci:set("commotion-dash", values["dashName"], 'gatherer', 'x.x.x.x')
Expand Down

0 comments on commit 8d38200

Please sign in to comment.