usermanager: Have methods not implemented in the active provider fall back to the null provider (later we can add support for chains of providers)
authorMatthew Wild <mwild1@gmail.com>
Tue, 04 Jan 2011 17:11:37 +0000
changeset 3992 73075b004e77
parent 3991 2b86d7705f4e
child 3993 b71e5ecc694b
usermanager: Have methods not implemented in the active provider fall back to the null provider (later we can add support for chains of providers)
core/usermanager.lua
--- a/core/usermanager.lua	Tue Jan 04 17:10:56 2011 +0000
+++ b/core/usermanager.lua	Tue Jan 04 17:11:37 2011 +0000
@@ -31,6 +31,8 @@
 	});
 end
 
+local provider_mt = { __index = new_null_provider() };
+
 function initialize_host(host)
 	local host_session = hosts[host];
 	if host_session.type ~= "local" then return; end
@@ -40,7 +42,7 @@
 		local auth_provider = config.get(host, "core", "authentication") or default_provider;
 		if config.get(host, "core", "anonymous_login") then auth_provider = "anonymous"; end -- COMPAT 0.7
 		if provider.name == auth_provider then
-			host_session.users = provider;
+			host_session.users = setmetatable(provider, provider_mt);
 		end
 		if host_session.users ~= nil and host_session.users.name ~= nil then
 			log("debug", "host '%s' now set to use user provider '%s'", host, host_session.users.name);