Mercurial > prosody-modules
changeset 2438:a528627e45ab
mod_auth_any: Remove provider constructor, it's only called once anyways
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 08 Jan 2017 11:27:01 +0100 |
parents | 75be377b74ea |
children | 1f7820f68868 |
files | mod_auth_any/mod_auth_any.lua |
diffstat | 1 files changed, 32 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_auth_any/mod_auth_any.lua Sun Jan 08 11:30:40 2017 +0100 +++ b/mod_auth_any/mod_auth_any.lua Sun Jan 08 11:27:01 2017 +0100 @@ -22,46 +22,42 @@ local prosody = _G.prosody; -function new_default_provider(host) - local provider = { name = "any" }; - log("debug", "initializing default authentication provider for host '%s'", host); - - function provider.test_password(username, password) - return true; - end +local host = module.host; +local provider = { name = "any" }; - function provider.set_password(username, password) - local account = datamanager.load(username, host, "accounts"); - if account then - account.password = password; - return datamanager.store(username, host, "accounts", account); - end - return nil, "Account not available."; - end +function provider.test_password(username, password) + return true; +end - function provider.user_exists(username) - return true; +function provider.set_password(username, password) + local account = datamanager.load(username, host, "accounts"); + if account then + account.password = password; + return datamanager.store(username, host, "accounts", account); end - - function provider.create_user(username, password) - return datamanager.store(username, host, "accounts", {password = password}); - end - - function provider.delete_user(username) - return datamanager.store(username, host, "accounts", nil); - end + return nil, "Account not available."; +end - function provider.get_sasl_handler() - local getpass_authentication_profile = { - plain_test = function(sasl, username, password, realm) - return true, true; - end - }; - return new_sasl(module.host, getpass_authentication_profile); - end - - return provider; +function provider.user_exists(username) + return true; end -module:add_item("auth-provider", new_default_provider(module.host)); +function provider.create_user(username, password) + return datamanager.store(username, host, "accounts", {password = password}); +end + +function provider.delete_user(username) + return datamanager.store(username, host, "accounts", nil); +end +function provider.get_sasl_handler() + local getpass_authentication_profile = { + plain_test = function(sasl, username, password, realm) + return true, true; + end + }; + return new_sasl(module.host, getpass_authentication_profile); +end + +module:add_item("auth-provider", provider); +