changeset 5745:628952e4ff47

mod_audit_user_accounts: Renamed from mod_audit_register
author Matthew Wild <mwild1@gmail.com>
date Thu, 30 Nov 2023 17:59:08 +0000
parents b4607c5dfcac
children 561503e0c0f1
files mod_audit_register/README.md mod_audit_register/mod_audit_register.lua mod_audit_user_accounts/README.md mod_audit_user_accounts/mod_audit_user_accounts.lua
diffstat 4 files changed, 70 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/mod_audit_register/README.md	Thu Nov 30 17:51:27 2023 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
----
-summary: Store registration events in the audit log
-rockspec:
-  dependencies:
-  - mod_audit
-...
-
-This module stores successful user registrations in the audit log provided by
-`mod_audit`.
--- a/mod_audit_register/mod_audit_register.lua	Thu Nov 30 17:51:27 2023 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-module:depends("audit");
--- luacheck: read globals module.audit
-
-local dt = require "util.datetime";
-local jid = require "util.jid";
-local st = require "util.stanza";
-
-local function audit_basic_event(name, custom_handler)
-	module:hook(name, function (event)
-		local custom;
-		if custom_handler then
-			custom = custom_handler(event);
-		end
-		module:audit(jid.join(event.username, module.host), name, {
-			session = event.session;
-			custom = custom;
-		});
-	end);
-end
-
-audit_basic_event("user-registered", function (event)
-	local invite = event.validated_invite or (event.session and event.session.validated_invite);
-	if not invite then return; end
-	return {
-		st.stanza(
-			"invite-used",
-			{
-				xmlns = "xmpp:prosody.im/audit",
-				token = invite.token,
-			}
-		);
-	};
-end);
-
-audit_basic_event("user-deregistered-pending");
-audit_basic_event("user-deregistered");
-
-audit_basic_event("user-enabled");
-audit_basic_event("user-disabled", function (event)
-	local meta = event.meta;
-	if not meta then return end
-
-	local meta_st = st.stanza("disabled", {
-		xmlns = "xmpp:prosody.im/audit";
-		reason = meta.reason;
-		when = meta.when and dt.datetime(meta.when) or nil;
-	});
-	if meta.comment then
-		meta_st:text_tag("comment", meta.comment);
-	end
-
-	return { meta_st };
-end);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_audit_user_accounts/README.md	Thu Nov 30 17:59:08 2023 +0000
@@ -0,0 +1,17 @@
+---
+summary: Store user account lifecycle events in the audit log
+rockspec:
+  dependencies:
+  - mod_audit
+...
+
+This module stores events related to user accounts in the audit log. Events
+include:
+
+- New user registered via IBR (user-registered)
+- User deleted their account via IBR (user-deregistered)
+- User requested deletion of their account (i.e. when a grace period is set) (user-deregistered-pending)
+- User account disabled
+- User account enabled
+
+There are no configuration options for this module. It depends on mod_audit.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_audit_user_accounts/mod_audit_user_accounts.lua	Thu Nov 30 17:59:08 2023 +0000
@@ -0,0 +1,53 @@
+module:depends("audit");
+-- luacheck: read globals module.audit
+
+local dt = require "util.datetime";
+local jid = require "util.jid";
+local st = require "util.stanza";
+
+local function audit_basic_event(name, custom_handler)
+	module:hook(name, function (event)
+		local custom;
+		if custom_handler then
+			custom = custom_handler(event);
+		end
+		module:audit(jid.join(event.username, module.host), name, {
+			session = event.session;
+			custom = custom;
+		});
+	end);
+end
+
+audit_basic_event("user-registered", function (event)
+	local invite = event.validated_invite or (event.session and event.session.validated_invite);
+	if not invite then return; end
+	return {
+		st.stanza(
+			"invite-used",
+			{
+				xmlns = "xmpp:prosody.im/audit",
+				token = invite.token,
+			}
+		);
+	};
+end);
+
+audit_basic_event("user-deregistered-pending");
+audit_basic_event("user-deregistered");
+
+audit_basic_event("user-enabled");
+audit_basic_event("user-disabled", function (event)
+	local meta = event.meta;
+	if not meta then return end
+
+	local meta_st = st.stanza("disabled", {
+		xmlns = "xmpp:prosody.im/audit";
+		reason = meta.reason;
+		when = meta.when and dt.datetime(meta.when) or nil;
+	});
+	if meta.comment then
+		meta_st:text_tag("comment", meta.comment);
+	end
+
+	return { meta_st };
+end);