[PATCH] mod_auth_internal_plain: Add functions to enable/disable/check user activation

Followup to 2cb5994e3f94. Implementaion taken from auth_internal_hashed is fully
compatible with plain one.

--
You received this message because you are subscribed to the Google Groups 
"prosody-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prosody-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prosody-dev/bdffc7dbb457df65549404e2163dfc9e%40vivaldi.net.
# HG changeset patch
# User Vitaly Orekhov <vkvo2...@vivaldi.net>
# Date 1679404857 -10800
#      Tue Mar 21 16:20:57 2023 +0300
# Node ID 29ca2aa9d5529648d752449373adacb2fb978d75
# Parent  2cb5994e3f947706ed1251c4e11a357affbd3183
mod_auth_internal_plain: Add functions to enable/disable/check user activation

Followup to 2cb5994e3f94. Implementaion taken from auth_internal_hashed is fully
compatible with plain one.

diff -r 2cb5994e3f94 -r 29ca2aa9d552 plugins/mod_auth_internal_plain.lua
--- a/plugins/mod_auth_internal_plain.lua	Tue Mar 21 01:46:47 2023 +0300
+++ b/plugins/mod_auth_internal_plain.lua	Tue Mar 21 16:20:57 2023 +0300
@@ -72,6 +72,27 @@
 	return true;
 end
 
+function provider.is_enabled(username) -- luacheck: ignore 212
+	local info, err = provider.get_account_info(username);
+	if not info then return nil, err; end
+	return info.enabled;
+end
+
+function provider.enable(username)
+	-- TODO map store?
+	local account = accounts:get(username);
+	account.disabled = nil;
+	account.updated = os.time();
+	return accounts:set(username, account);
+end
+
+function provider.disable(username)
+	local account = accounts:get(username);
+	account.disabled = true;
+	account.updated = os.time();
+	return accounts:set(username, account);
+end
+
 function provider.users()
 	return accounts:users();
 end

Reply via email to