From d9a018a75002bba009e60eaa87a5fb8276233c4e Mon Sep 17 00:00:00 2001 From: erdgeist Date: Sun, 2 Aug 2026 18:59:08 +0200 Subject: Witness account creation --- app/models/node_action.rb | 13 +++++++------ app/models/user.rb | 11 +++++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) (limited to 'app/models') diff --git a/app/models/node_action.rb b/app/models/node_action.rb index d619aac5..82a3ef44 100644 --- a/app/models/node_action.rb +++ b/app/models/node_action.rb @@ -98,12 +98,13 @@ class NodeAction < ApplicationRecord # "detached_from" -- array of unique_names, only when any # "headline_removed_from" -- array of unique_names, only when any # - # "otp_enroll" / "otp_disable" / "otp_reset" / "user_deactivate" / - # "user_reactivate" (second-factor lifecycle; node column nil; - # participants: the affected User - # User-typed subject. otp_disable is self-service; otp_reset is an - # administrator clearing someone else's factor, where actor and - # participant differ): + # "otp_enroll" / "otp_disable" / "otp_reset" (second-factor + # lifecycle) and "user_create" / "user_deactivate" / + # "user_reactivate" (account lifecycle). Node column nil; + # participants: the affected User, a User-typed subject. + # otp_disable is self-service; otp_reset and all three account + # verbs are an administrator acting on someone else, so actor and + # participant differ: # "target_login" -- flat string, the affected account's login # # Reserved: "demote" (via "trash" | "depublish") for an explicit diff --git a/app/models/user.rb b/app/models/user.rb index 4b70ebe5..49c22584 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -117,6 +117,17 @@ class User < ApplicationRecord redaktion? end + def save_witnessed(actor:) + saved = false + transaction do + saved = save + raise ActiveRecord::Rollback unless saved + NodeAction.record!(:participants => [self], :user => actor, + :action => "user_create", :target_login => login) + end + saved + end + def deactivate!(actor:) return false if alumni? transaction do -- cgit v1.3