From 6847889d76664bb997b4b1b014c7126a5f86e2b1 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Wed, 22 Jun 2016 13:52:43 -0600 Subject: [PATCH] Add domain_uuid check to pin_number.lua. --- resources/install/scripts/pin_number.lua | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/resources/install/scripts/pin_number.lua b/resources/install/scripts/pin_number.lua index 5c72c5e81b..ee7b81fb3c 100644 --- a/resources/install/scripts/pin_number.lua +++ b/resources/install/scripts/pin_number.lua @@ -53,18 +53,39 @@ --define the check pin number function function check_pin_number() + --sleep session:sleep(500); + --increment the number of tries tries = tries + 1; + + --get the domain_uuid + domain_uuid = session:getVariable("domain_uuid"); + if (domain_uuid == nil) then + --get the domain_name + domain_name = session:getVariable("domain_name"); + --get the domain_uuid using the domain_name + sql = [[SELECT domain_name FROM v_domains + WHERE domain_name = ']] .. domain_name ..[[' ]]; + if (debug["sql"]) then + freeswitch.consoleLog("NOTICE", "SQL: "..sql.."\n"); + end + dbh:query(sql, function(row) + domain_uuid = row["domain_uuid"]; + end); + end + --get the user pin number min_digits = 2; max_digits = 20; digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:voicemail_enter_pass:#", "", "\\d+"); + --validate the user pin number if (pin_number == "database") then sql = [[SELECT * FROM v_pin_numbers WHERE pin_number = ']] .. digits ..[[' + AND domain_uuid = ']] .. domain_uuid .. [[' AND enabled = 'true' ]]; if (debug["sql"]) then freeswitch.consoleLog("NOTICE", "SQL: "..sql.."\n"); @@ -72,7 +93,6 @@ auth = false; dbh:query(sql, function(row) --get the values from the database - domain_uuid = row["domain_uuid"]; accountcode = row["accountcode"]; --set the variable to true auth = true;