Added support for authentication via voicemail box passwords (#3076)

This commit is contained in:
Caleb
2018-05-30 18:52:52 -07:00
committed by FusionPBX
parent 66a5d9e92c
commit bc6a58aa30
2 changed files with 48 additions and 0 deletions

View File

@@ -79,6 +79,21 @@
end);
end
--introduce authentication process
session:streamFile("phrase:pin_number_start:#");
--get the user ext, if applicable
if (pin_number == "voicemail") then
min_digits = 1;
max_digits = 6;
user_ext = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:pin_number_enter_extension:#", "", "\\d+");
if (not user_ext or user_ext == "") then
session:streamFile("phrase:voicemail_fail_auth:#");
session:hangup("NORMAL_CLEARING");
return;
end
end
--get the user pin number
min_digits = 2;
max_digits = 20;
@@ -107,6 +122,23 @@
--set the authorized pin number that was used
session:setVariable("pin_number", digits);
end);
elseif (pin_number == "voicemail") then
local sql = [[SELECT * FROM v_voicemails
WHERE voicemail_id = :user_ext
AND voicemail_password = :digits
AND domain_uuid = :domain_uuid
AND voicemail_enabled = 'true' ]];
local params = {user_ext = user_ext, digits = digits, domain_uuid = domain_uuid};
if (debug["sql"]) then
freeswitch.consoleLog("NOTICE", "[pin_number] SQL: "..sql.."; params: " .. json.encode(params) .. "\n");
end
auth = false;
dbh:query(sql, params, function(row)
--set the variable to true
auth = true;
--set the authorized pin number that was used
session:setVariable("pin_number", digits);
end);
else
pin_number_table = explode(",",pin_number);
for index,pin_number in pairs(pin_number_table) do