Mercurial > prosody-hg
comparison core/usermanager.lua @ 3036:0714539bcf71
usermanager: Handle auth providers for components.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Thu, 13 May 2010 21:18:03 +0500 |
| parents | 5584c928d1f7 |
| children | 0319abdcf04f |
comparison
equal
deleted
inserted
replaced
| 3035:5584c928d1f7 | 3036:0714539bcf71 |
|---|---|
| 20 | 20 |
| 21 module "usermanager" | 21 module "usermanager" |
| 22 | 22 |
| 23 local new_default_provider; | 23 local new_default_provider; |
| 24 | 24 |
| 25 prosody.events.add_handler("host-activated", function (host) | 25 local function host_handler(host) |
| 26 local host_session = hosts[host]; | 26 local host_session = hosts[host]; |
| 27 host_session.events.add_handler("item-added/auth-provider", function (provider) | 27 host_session.events.add_handler("item-added/auth-provider", function (provider) |
| 28 if config.get(host, "core", "authentication") == provider.name then | 28 if config.get(host, "core", "authentication") == provider.name then |
| 29 host_session.users = provider; | 29 host_session.users = provider; |
| 30 end | 30 end |
| 33 if host_session.users == provider then | 33 if host_session.users == provider then |
| 34 host_session.users = new_default_provider(host); | 34 host_session.users = new_default_provider(host); |
| 35 end | 35 end |
| 36 end); | 36 end); |
| 37 host_session.users = new_default_provider(host); -- Start with the default usermanager provider | 37 host_session.users = new_default_provider(host); -- Start with the default usermanager provider |
| 38 end); | 38 end |
| 39 prosody.events.add_handler("host-activated", host_handler); | |
| 40 prosody.events.add_handler("component-activated", host_handler); | |
| 39 | 41 |
| 40 local function is_cyrus(host) return config.get(host, "core", "sasl_backend") == "cyrus"; end | 42 local function is_cyrus(host) return config.get(host, "core", "sasl_backend") == "cyrus"; end |
| 41 | 43 |
| 42 function new_default_provider(host) | 44 function new_default_provider(host) |
| 43 local provider = { name = "default" }; | 45 local provider = { name = "default" }; |
