core/usermanager.lua

changeset 3159
db9def53fe9c
parent 3158
a23168cc4af5
child 3161
3c46cb94caed
equal deleted inserted replaced
3158:a23168cc4af5 3159:db9def53fe9c
24 24
25 module "usermanager" 25 module "usermanager"
26 26
27 function new_null_provider() 27 function new_null_provider()
28 local function dummy() end; 28 local function dummy() end;
29 return setmetatable({}, { __index = function() return dummy; end }); 29 return setmetatable({name = "dummyauth"}, { __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 log("debug", "host_handler called with host '%s'", host);
34 local host_session = hosts[host]; 34 local host_session = hosts[host];
37 if provider == nil then 37 if provider == nil then
38 log("debug", "auth provider is nil"); 38 log("debug", "auth provider is nil");
39 else 39 else
40 log("debug", "auth provider is not nil"); 40 log("debug", "auth provider is not nil");
41 end 41 end
42 if provider.name == nil then
43 log("debug", "authentication provider name is nil");
44 else
45 log("debug", "authentication provider name = '%s'", provider.name);
46 end
42 if config.get(host, "core", "authentication") == nil and provider.name == "default" then 47 if config.get(host, "core", "authentication") == nil and provider.name == "default" then
43 host_session.users = provider; 48 host_session.users = provider;
44 elseif config.get(host, "core", "authentication") == provider.name then 49 elseif config.get(host, "core", "authentication") == provider.name then
45 host_session.users = provider; 50 host_session.users = provider;
46 end 51 end
47 if provider.name == nil then 52 if host_session.users ~= nil and host_session.users.name ~= nil then
48 log("debug", "authentication provider name is nil"); 53 log("debug", "host_session.users.name for host '%s' now '%s'", host, host_session.users.name);
49 else
50 log("debug", "authentication provider name = '%s'", provider.name);
51 end 54 end
52 end); 55 end);
53 host_session.events.add_handler("item-removed/auth-provider", function (event) 56 host_session.events.add_handler("item-removed/auth-provider", function (event)
54 local provider = event.item; 57 local provider = event.item;
55 if host_session.users == provider then 58 if host_session.users == provider then
60 prosody.events.add_handler("host-activated", host_handler, 100); 63 prosody.events.add_handler("host-activated", host_handler, 100);
61 prosody.events.add_handler("component-activated", host_handler, 100); 64 prosody.events.add_handler("component-activated", host_handler, 100);
62 65
63 function is_cyrus(host) return config.get(host, "core", "sasl_backend") == "cyrus"; end 66 function is_cyrus(host) return config.get(host, "core", "sasl_backend") == "cyrus"; end
64 67
65 function validate_credentials(host, username, password, method) 68 function test_password(username, password, host)
66 return hosts[host].users.test_password(username, password); 69 return hosts[host].users.test_password(username, password);
67 end 70 end
68 71
69 function get_password(username, host) 72 function get_password(username, host)
70 return hosts[host].users.get_password(username); 73 return hosts[host].users.get_password(username);
71 end 74 end
72 75
73 function set_password(username, host, password) 76 function set_password(username, password, host)
74 return hosts[host].users.set_password(username, password); 77 return hosts[host].users.set_password(username, password);
75 end 78 end
76 79
77 function user_exists(username, host) 80 function user_exists(username, host)
78 return hosts[host].users.user_exists(username); 81 return hosts[host].users.user_exists(username);

mercurial