summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-08-02 18:59:08 +0200
committererdgeist <erdgeist@erdgeist.org>2026-08-02 18:59:08 +0200
commitd9a018a75002bba009e60eaa87a5fb8276233c4e (patch)
tree33335d1c861b01039e13b6e94be214e1b284eb6a /app/models
parent833c59abf109943e857f64e526f6434e095242d6 (diff)
Witness account creation
Diffstat (limited to 'app/models')
-rw-r--r--app/models/node_action.rb13
-rw-r--r--app/models/user.rb11
2 files changed, 18 insertions, 6 deletions
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
98 # "detached_from" -- array of unique_names, only when any 98 # "detached_from" -- array of unique_names, only when any
99 # "headline_removed_from" -- array of unique_names, only when any 99 # "headline_removed_from" -- array of unique_names, only when any
100 # 100 #
101 # "otp_enroll" / "otp_disable" / "otp_reset" / "user_deactivate" / 101 # "otp_enroll" / "otp_disable" / "otp_reset" (second-factor
102 # "user_reactivate" (second-factor lifecycle; node column nil; 102 # lifecycle) and "user_create" / "user_deactivate" /
103 # participants: the affected User 103 # "user_reactivate" (account lifecycle). Node column nil;
104 # User-typed subject. otp_disable is self-service; otp_reset is an 104 # participants: the affected User, a User-typed subject.
105 # administrator clearing someone else's factor, where actor and 105 # otp_disable is self-service; otp_reset and all three account
106 # participant differ): 106 # verbs are an administrator acting on someone else, so actor and
107 # participant differ:
107 # "target_login" -- flat string, the affected account's login 108 # "target_login" -- flat string, the affected account's login
108 # 109 #
109 # Reserved: "demote" (via "trash" | "depublish") for an explicit 110 # 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
117 redaktion? 117 redaktion?
118 end 118 end
119 119
120 def save_witnessed(actor:)
121 saved = false
122 transaction do
123 saved = save
124 raise ActiveRecord::Rollback unless saved
125 NodeAction.record!(:participants => [self], :user => actor,
126 :action => "user_create", :target_login => login)
127 end
128 saved
129 end
130
120 def deactivate!(actor:) 131 def deactivate!(actor:)
121 return false if alumni? 132 return false if alumni?
122 transaction do 133 transaction do