# HG changeset patch # User Kim Alvefur # Date 1483871221 -3600 # Node ID a528627e45abc53d58ab55047705c1f246b1cbbe # Parent 75be377b74ea4273ae8b8a80bf2d63851c6afbf4 mod_auth_any: Remove provider constructor, it's only called once anyways diff -r 75be377b74ea -r a528627e45ab mod_auth_any/mod_auth_any.lua --- 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); +