Add additional auhtorized checks and comment out debugging code.

This commit is contained in:
Mark Crane 2015-05-01 12:57:06 +00:00
parent 28508d1557
commit 9b2cac9d34
1 changed files with 11 additions and 14 deletions

View File

@ -91,12 +91,12 @@
user = user_table[1]; user = user_table[1];
domain = user_table[2]; domain = user_table[2];
--show the phone that will be overiddent --show the phone that will be overridden
freeswitch.consoleLog("NOTICE", "[provision] sip_from_uri: ".. sip_from_uri .. " [69]\n"); freeswitch.consoleLog("NOTICE", "[provision] sip_from_uri: ".. sip_from_uri .. " [69]\n");
freeswitch.consoleLog("NOTICE", "[provision] user: ".. user .. "\n"); freeswitch.consoleLog("NOTICE", "[provision] user: ".. user .. "\n");
freeswitch.consoleLog("NOTICE", "[provision] domain: ".. domain .. "\n"); freeswitch.consoleLog("NOTICE", "[provision] domain: ".. domain .. "\n");
--get the device uuid for the phone that will have its configuration overriden --get the device uuid for the phone that will have its configuration overridden
sql = [[SELECT * FROM v_device_lines ]]; sql = [[SELECT * FROM v_device_lines ]];
sql = sql .. [[WHERE user_id = ']] .. user .. [[' ]]; sql = sql .. [[WHERE user_id = ']] .. user .. [[' ]];
sql = sql .. [[AND server_address = ']]..domain..[[' ]]; sql = sql .. [[AND server_address = ']]..domain..[[' ]];
@ -136,7 +136,7 @@
end); end);
--get the device uuid of the mobile provision --get the device uuid of the mobile provision
--if (user_id and password) then if (user_id and password) then
sql = [[SELECT * FROM v_devices ]]; sql = [[SELECT * FROM v_devices ]];
sql = sql .. [[WHERE device_username = ']]..user_id..[[' ]]; sql = sql .. [[WHERE device_username = ']]..user_id..[[' ]];
sql = sql .. [[AND device_password = ']]..password..[[' ]] sql = sql .. [[AND device_password = ']]..password..[[' ]]
@ -150,32 +150,29 @@
--authorize the user --authorize the user
authorized = 'true'; authorized = 'true';
end); end);
--end end
--authentication failed --authentication failed
if (authorized == 'false') then if (authorized == 'false') then
result = session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/voicemail/vm-fail_auth.wav"); result = session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/voicemail/vm-fail_auth.wav");
end end
--send the action to the log --add the override to the device uuid (login)
freeswitch.consoleLog("NOTICE", "[provision] action: ".. action .. "\n"); if (authorized == 'true' and action == "login") then
--add the ovveride to the device uuid (login)
if (action == "login") then
if (device_uuid_alternate ~= nil) then if (device_uuid_alternate ~= nil) then
sql = [[UPDATE v_devices SET device_uuid_alternate = ']]..device_uuid_alternate..[[']]; sql = [[UPDATE v_devices SET device_uuid_alternate = ']]..device_uuid_alternate..[[']];
sql = sql .. [[WHERE device_uuid = ']]..device_uuid..[[' ]]; sql = sql .. [[WHERE device_uuid = ']]..device_uuid..[[' ]];
freeswitch.consoleLog("NOTICE", "[provision] sql: ".. sql .. "\n"); --freeswitch.consoleLog("NOTICE", "[provision] sql: ".. sql .. "\n");
dbh:query(sql); dbh:query(sql);
end end
end end
--remove the ovveride to the device uuid (logout) --remove the override to the device uuid (logout)
if (action == "logout") then if (authorized == 'true' and action == "logout") then
if (device_uuid_alternate ~= nil) then if (device_uuid_alternate ~= nil) then
sql = [[UPDATE v_devices SET device_uuid_alternate = null ]]; sql = [[UPDATE v_devices SET device_uuid_alternate = null ]];
sql = sql .. [[WHERE device_uuid_alternate = ']]..device_uuid..[[' ]]; sql = sql .. [[WHERE device_uuid_alternate = ']]..device_uuid..[[' ]];
freeswitch.consoleLog("NOTICE", "[provision] sql: ".. sql .. "\n"); --freeswitch.consoleLog("NOTICE", "[provision] sql: ".. sql .. "\n");
dbh:query(sql); dbh:query(sql);
end end
end end