Software / code / prosody
Comparison
core/usermanager.lua @ 3161:73e93a48c0c1
Update usermanager to not crash, etc.
| author | Jeff Mitchell <jeff@jefferai.org> |
|---|---|
| date | Thu, 20 May 2010 14:18:12 -0400 |
| parent | 3160:9064dd006b21 |
| child | 3163:a23168cc4af5 |
comparison
equal
deleted
inserted
replaced
| 3160:9064dd006b21 | 3161:73e93a48c0c1 |
|---|---|
| 18 | 18 |
| 19 local require_provisioning = config.get("*", "core", "cyrus_require_provisioning") or false; | 19 local require_provisioning = config.get("*", "core", "cyrus_require_provisioning") or false; |
| 20 | 20 |
| 21 local prosody = _G.prosody; | 21 local prosody = _G.prosody; |
| 22 | 22 |
| 23 local setmetatable = setmetatable; | |
| 24 | |
| 23 module "usermanager" | 25 module "usermanager" |
| 26 | |
| 27 function new_null_provider() | |
| 28 local function dummy() end; | |
| 29 return setmetatable({}, { __index = function() return dummy; end }); | |
| 30 end | |
| 24 | 31 |
| 25 local function host_handler(host) | 32 local function host_handler(host) |
| 26 local host_session = hosts[host]; | 33 local host_session = hosts[host]; |
| 27 host_session.events.add_handler("item-added/auth-provider", function (provider) | 34 host_session.events.add_handler("item-added/auth-provider", function (provider) |
| 28 log("debug", "authentication provider = '%s'", config.get(host, "core", "authentication")); | 35 log("debug", "authentication provider = '%s'", config.get(host, "core", "authentication")); |
| 30 host_session.users = provider; | 37 host_session.users = provider; |
| 31 end | 38 end |
| 32 end); | 39 end); |
| 33 host_session.events.add_handler("item-removed/auth-provider", function (provider) | 40 host_session.events.add_handler("item-removed/auth-provider", function (provider) |
| 34 if host_session.users == provider then | 41 if host_session.users == provider then |
| 35 userplugins.new_default_provider(host); | 42 host_session.users = new_null_provider(); |
| 36 end | 43 end |
| 37 end); | 44 end); |
| 38 if host_session.users ~= nil then | |
| 39 log("debug", "using non-default authentication provider"); | |
| 40 else | |
| 41 log("debug", "using default authentication provider"); | |
| 42 host_session.users = new_default_provider(host); -- Start with the default usermanager provider | |
| 43 end | |
| 44 end | 45 end |
| 45 prosody.events.add_handler("host-activated", host_handler); | 46 prosody.events.add_handler("host-activated", host_handler); |
| 46 prosody.events.add_handler("component-activated", host_handler); | 47 prosody.events.add_handler("component-activated", host_handler); |
| 47 | 48 |
| 48 local function is_cyrus(host) return config.get(host, "core", "sasl_backend") == "cyrus"; end | 49 local function is_cyrus(host) return config.get(host, "core", "sasl_backend") == "cyrus"; end |