Comparison

core/usermanager.lua @ 3163:a23168cc4af5

Working defaultauth
author Jeff Mitchell <jeff@jefferai.org>
date Thu, 20 May 2010 18:06:21 -0400
parent 3161:73e93a48c0c1
child 3164:db9def53fe9c
comparison
equal deleted inserted replaced
3162:f246719abcd2 3163:a23168cc4af5
28 local function dummy() end; 28 local function dummy() end;
29 return setmetatable({}, { __index = function() return dummy; end }); 29 return setmetatable({}, { __index = function() return dummy; end });
30 end 30 end
31 31
32 local function host_handler(host) 32 local function host_handler(host)
33 log("debug", "host_handler called with host '%s'", host);
33 local host_session = hosts[host]; 34 local host_session = hosts[host];
34 host_session.events.add_handler("item-added/auth-provider", function (provider) 35 host_session.events.add_handler("item-added/auth-provider", function (event)
35 log("debug", "authentication provider = '%s'", config.get(host, "core", "authentication")); 36 local provider = event.item;
36 if config.get(host, "core", "authentication") == provider.name then 37 if provider == nil then
38 log("debug", "auth provider is nil");
39 else
40 log("debug", "auth provider is not nil");
41 end
42 if config.get(host, "core", "authentication") == nil and provider.name == "default" then
43 host_session.users = provider;
44 elseif config.get(host, "core", "authentication") == provider.name then
37 host_session.users = provider; 45 host_session.users = provider;
38 end 46 end
47 if provider.name == nil then
48 log("debug", "authentication provider name is nil");
49 else
50 log("debug", "authentication provider name = '%s'", provider.name);
51 end
39 end); 52 end);
40 host_session.events.add_handler("item-removed/auth-provider", function (provider) 53 host_session.events.add_handler("item-removed/auth-provider", function (event)
54 local provider = event.item;
41 if host_session.users == provider then 55 if host_session.users == provider then
42 host_session.users = new_null_provider(); 56 host_session.users = new_null_provider();
43 end 57 end
44 end); 58 end);
45 end 59 end
46 prosody.events.add_handler("host-activated", host_handler); 60 prosody.events.add_handler("host-activated", host_handler, 100);
47 prosody.events.add_handler("component-activated", host_handler); 61 prosody.events.add_handler("component-activated", host_handler, 100);
48 62
49 local function is_cyrus(host) return config.get(host, "core", "sasl_backend") == "cyrus"; end 63 function is_cyrus(host) return config.get(host, "core", "sasl_backend") == "cyrus"; end
50 64
51 function validate_credentials(host, username, password, method) 65 function validate_credentials(host, username, password, method)
52 return hosts[host].users.test_password(username, password); 66 return hosts[host].users.test_password(username, password);
53 end 67 end
54 68
87 end 101 end
88 return nil; 102 return nil;
89 end 103 end
90 end 104 end
91 105
92 _M.new_default_provider = new_default_provider;
93
94 return _M; 106 return _M;