Update index.lua
Improve on the call center agent status use agent_authorized true instead of auto_authorized.
This commit is contained in:
@@ -27,9 +27,9 @@
|
|||||||
domain_name = session:getVariable("domain_name");
|
domain_name = session:getVariable("domain_name");
|
||||||
context = session:getVariable("context");
|
context = session:getVariable("context");
|
||||||
uuid = session:get_uuid();
|
uuid = session:get_uuid();
|
||||||
|
agent_authorized = session:getVariable("agent_authorized");
|
||||||
agent_id = session:getVariable("agent_id");
|
agent_id = session:getVariable("agent_id");
|
||||||
agent_password = session:getVariable("agent_password");
|
agent_password = session:getVariable("agent_password");
|
||||||
auto_authorized = session:getVariable("auto_authorized");
|
|
||||||
|
|
||||||
--set the sounds path for the language, dialect and voice
|
--set the sounds path for the language, dialect and voice
|
||||||
default_language = session:getVariable("default_language");
|
default_language = session:getVariable("default_language");
|
||||||
@@ -40,6 +40,11 @@
|
|||||||
if (not default_voice) then default_voice = 'callie'; end
|
if (not default_voice) then default_voice = 'callie'; end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--set default as access denied
|
||||||
|
if (agent_authorized == nil or agent_authorized ~= 'true') then
|
||||||
|
agent_authorized = 'false';
|
||||||
|
end
|
||||||
|
|
||||||
--define the sounds directory
|
--define the sounds directory
|
||||||
sounds_dir = session:getVariable("sounds_dir");
|
sounds_dir = session:getVariable("sounds_dir");
|
||||||
sounds_dir = sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice;
|
sounds_dir = sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice;
|
||||||
@@ -52,48 +57,40 @@
|
|||||||
agent_id = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:voicemail_enter_id:#", "", "\\d+");
|
agent_id = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:voicemail_enter_id:#", "", "\\d+");
|
||||||
end
|
end
|
||||||
|
|
||||||
--get the pin number from the caller if not auto_authorized
|
--get the pin number from the caller
|
||||||
if (auto_authorized == nil) then
|
if (agent_password == nil and agent_authorized ~= 'true')) then
|
||||||
if (agent_password == nil) then
|
min_digits = 3;
|
||||||
min_digits = 3;
|
max_digits = 20;
|
||||||
max_digits = 20;
|
max_tries = 3;
|
||||||
max_tries = 3;
|
agent_password = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:voicemail_enter_pass:#", "", "\\d+");
|
||||||
agent_password = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:voicemail_enter_pass:#", "", "\\d+");
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--set default as access denied
|
|
||||||
authorized = 'false';
|
|
||||||
|
|
||||||
--get the agent password
|
--get the agent password
|
||||||
sql = "SELECT * FROM v_call_center_agents ";
|
sql = "SELECT * FROM v_call_center_agents ";
|
||||||
sql = sql .. "WHERE domain_uuid = '" .. domain_uuid .."' ";
|
sql = sql .. "WHERE domain_uuid = '" .. domain_uuid .."' ";
|
||||||
sql = sql .. "AND agent_id = '" .. agent_id .."' ";
|
sql = sql .. "AND agent_id = '" .. agent_id .."' ";
|
||||||
|
if (agent_authorized ~= 'true') then
|
||||||
--only use password clause if not auto_authorized
|
|
||||||
if (auto_authorized == nil) then
|
|
||||||
sql = sql .. "AND agent_password = '" .. agent_password .."' ";
|
sql = sql .. "AND agent_password = '" .. agent_password .."' ";
|
||||||
end
|
end
|
||||||
|
|
||||||
freeswitch.consoleLog("notice", "[user status] sql: " .. sql .. "\n");
|
freeswitch.consoleLog("notice", "[user status] sql: " .. sql .. "\n");
|
||||||
dbh:query(sql, function(row)
|
dbh:query(sql, function(row)
|
||||||
--set the variables
|
--set the variables
|
||||||
agent_name = row.agent_name;
|
agent_name = row.agent_name;
|
||||||
agent_id = row.agent_id;
|
agent_id = row.agent_id;
|
||||||
--authorize the user
|
--authorize the user
|
||||||
authorized = 'true';
|
agent_authorized = 'true';
|
||||||
end);
|
end);
|
||||||
|
|
||||||
--show the results
|
--show the results
|
||||||
if (agent_id) then
|
if (agent_id) then
|
||||||
freeswitch.consoleLog("notice", "[user status][login] agent_id: " .. agent_id .. " authorized " .. authorized .. "\n");
|
freeswitch.consoleLog("notice", "[user status][login] agent id: " .. agent_id .. " authorized: " .. agent_authorized .. "\n");
|
||||||
end
|
end
|
||||||
if (agent_password and debug["password"]) then
|
if (agent_password and debug["password"]) then
|
||||||
freeswitch.consoleLog("notice", "[user status][login] agent_password: " .. agent_password .. "\n");
|
freeswitch.consoleLog("notice", "[user status][login] agent password: " .. agent_password .. "\n");
|
||||||
end
|
end
|
||||||
|
|
||||||
--get the user_uuid
|
--get the user_uuid
|
||||||
if (authorized == 'true') then
|
if (agent_authorized == 'true') then
|
||||||
sql = "SELECT user_uuid, user_status FROM v_users ";
|
sql = "SELECT user_uuid, user_status FROM v_users ";
|
||||||
sql = sql .. "WHERE username = '".. agent_name .."' ";
|
sql = sql .. "WHERE username = '".. agent_name .."' ";
|
||||||
sql = sql .. "AND domain_uuid = '" .. domain_uuid .."' ";
|
sql = sql .. "AND domain_uuid = '" .. domain_uuid .."' ";
|
||||||
@@ -164,7 +161,7 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
--unauthorized
|
--unauthorized
|
||||||
if (authorized == 'false') then
|
if (agent_authorized == 'false') then
|
||||||
result = session:streamFile(sounds_dir.."/voicemail/vm-fail_auth.wav");
|
result = session:streamFile(sounds_dir.."/voicemail/vm-fail_auth.wav");
|
||||||
status = "Invalid ID or Password";
|
status = "Invalid ID or Password";
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user