Prevent a bad domain_name from causing a nil error for reverse authentication.
This commit is contained in:
+6
-8
@@ -1,6 +1,6 @@
|
|||||||
-- xml_handler.lua
|
-- xml_handler.lua
|
||||||
-- Part of FusionPBX
|
-- Part of FusionPBX
|
||||||
-- Copyright (C) 2013 Mark J Crane <markjcrane@fusionpbx.com>
|
-- Copyright (C) 2013-2015 Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
-- All rights reserved.
|
-- All rights reserved.
|
||||||
--
|
--
|
||||||
-- Redistribution and use in source and binary forms, with or without
|
-- Redistribution and use in source and binary forms, with or without
|
||||||
@@ -39,8 +39,7 @@
|
|||||||
assert(dbh:connected());
|
assert(dbh:connected());
|
||||||
|
|
||||||
--get the domain_uuid
|
--get the domain_uuid
|
||||||
if (domain_uuid == nil) then
|
if (domain_uuid == nil and domain_name ~= nil) then
|
||||||
--get the domain_uuid
|
|
||||||
if (domain_name ~= nil) then
|
if (domain_name ~= nil) then
|
||||||
sql = "SELECT domain_uuid FROM v_domains ";
|
sql = "SELECT domain_uuid FROM v_domains ";
|
||||||
sql = sql .. "WHERE domain_name = '" .. domain_name .."' ";
|
sql = sql .. "WHERE domain_name = '" .. domain_name .."' ";
|
||||||
@@ -51,14 +50,10 @@
|
|||||||
domain_uuid = rows["domain_uuid"];
|
domain_uuid = rows["domain_uuid"];
|
||||||
end);
|
end);
|
||||||
end
|
end
|
||||||
--if the domain_uuid is null then set an empty string
|
|
||||||
if (domain_uuid == nil) then
|
|
||||||
domain_uuid = " ";
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--get the extension information
|
--get the extension information
|
||||||
|
if (domain_uuid ~= nil) then
|
||||||
sql = "SELECT * FROM v_extensions WHERE domain_uuid = '" .. domain_uuid .. "' and (extension = '" .. user .. "' or number_alias = '" .. user .. "') and enabled = 'true' ";
|
sql = "SELECT * FROM v_extensions WHERE domain_uuid = '" .. domain_uuid .. "' and (extension = '" .. user .. "' or number_alias = '" .. user .. "') and enabled = 'true' ";
|
||||||
if (debug["sql"]) then
|
if (debug["sql"]) then
|
||||||
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n");
|
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n");
|
||||||
@@ -79,8 +74,10 @@
|
|||||||
--params
|
--params
|
||||||
password = row.password;
|
password = row.password;
|
||||||
end);
|
end);
|
||||||
|
end
|
||||||
|
|
||||||
--build the xml
|
--build the xml
|
||||||
|
if (domain_name ~= nil and extension ~= nil and password ~= nil) then
|
||||||
local xml = {}
|
local xml = {}
|
||||||
--table.insert(xml, [[<?xml version="1.0" encoding="UTF-8" standalone="no"?>]]);
|
--table.insert(xml, [[<?xml version="1.0" encoding="UTF-8" standalone="no"?>]]);
|
||||||
table.insert(xml, [[<document type="freeswitch/xml">]]);
|
table.insert(xml, [[<document type="freeswitch/xml">]]);
|
||||||
@@ -96,6 +93,7 @@
|
|||||||
table.insert(xml, [[ </section>]]);
|
table.insert(xml, [[ </section>]]);
|
||||||
table.insert(xml, [[</document>]]);
|
table.insert(xml, [[</document>]]);
|
||||||
XML_STRING = table.concat(xml, "\n");
|
XML_STRING = table.concat(xml, "\n");
|
||||||
|
end
|
||||||
|
|
||||||
--close the database connection
|
--close the database connection
|
||||||
dbh:release();
|
dbh:release();
|
||||||
|
|||||||
Reference in New Issue
Block a user