mod_auth_anonymous: Add config option to allow/disallow storage writes
authorMatthew Wild <mwild1@gmail.com>
Fri, 02 Oct 2020 16:44:30 +0100
changeset 11126 d60094d9b458
parent 11125 2d38242a08dd
child 11129 5bcddab1659b
mod_auth_anonymous: Add config option to allow/disallow storage writes
plugins/mod_auth_anonymous.lua
--- a/plugins/mod_auth_anonymous.lua	Fri Oct 02 16:35:05 2020 +0200
+++ b/plugins/mod_auth_anonymous.lua	Fri Oct 02 16:44:30 2020 +0100
@@ -11,6 +11,8 @@
 local datamanager = require "util.datamanager";
 local hosts = prosody.hosts;
 
+local allow_storage = module:get_option_boolean("allow_anonymous_storage", false);
+
 -- define auth provider
 local provider = {};
 
@@ -62,10 +64,14 @@
 end
 
 function module.load()
-	datamanager.add_callback(dm_callback);
+	if not allow_storage then
+		datamanager.add_callback(dm_callback);
+	end
 end
 function module.unload()
-	datamanager.remove_callback(dm_callback);
+	if not allow_storage then
+		datamanager.remove_callback(dm_callback);
+	end
 end
 
 module:provides("auth", provider);