mod_auth_http_async/mod_auth_http_async.lua
changeset 2815 39156d6f7268
parent 2754 1d139e33c502
--- a/mod_auth_http_async/mod_auth_http_async.lua	Sat Oct 28 17:17:59 2017 +0200
+++ b/mod_auth_http_async/mod_auth_http_async.lua	Tue Oct 31 19:31:54 2017 +0100
@@ -26,9 +26,17 @@
 if rawget(_G, "base_parsed") == nil then
 	rawset(_G, "base_parsed", false)
 end
+if not have_async then -- FINE! Set your globals then
+	prosody.unlock_globals()
+	require "ltn12"
+	require "socket"
+	require "socket.http"
+	require "ssl.https"
+	prosody.lock_globals()
+end
 
 local function async_http_auth(url, username, password)
-module:log("debug", "async_http_auth()");
+	module:log("debug", "async_http_auth()");
 	local http = require "net.http";
 	local wait, done = async.waiter();
 	local content, code, request, response;
@@ -51,7 +59,8 @@
 end
 
 local function sync_http_auth(url,username, password)
-module:log("debug", "sync_http_auth()");
+	module:log("debug", "sync_http_auth()");
+	require "ltn12";
 	local http = require "socket.http";
 	local https = require "ssl.https";
 	local request;
@@ -113,4 +122,4 @@
 	});
 end
 
-module:provides("auth", provider);
\ No newline at end of file
+module:provides("auth", provider);