diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/users_controller.rb | 2 | ||||
| -rw-r--r-- | app/helpers/node_actions_helper.rb | 10 | ||||
| -rw-r--r-- | app/models/node_action.rb | 13 | ||||
| -rw-r--r-- | app/models/user.rb | 11 |
4 files changed, 27 insertions, 9 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9b9d64e5..7932e28b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb | |||
| @@ -31,7 +31,7 @@ class UsersController < ApplicationController | |||
| 31 | def create | 31 | def create |
| 32 | @user = User.new user_params | 32 | @user = User.new user_params |
| 33 | 33 | ||
| 34 | if @user.save | 34 | if @user.save_witnessed(:actor => current_user) |
| 35 | flash[:notice] = t("flash.users.created", :login => @user.login) | 35 | flash[:notice] = t("flash.users.created", :login => @user.login) |
| 36 | redirect_to user_path(@user) | 36 | redirect_to user_path(@user) |
| 37 | else | 37 | else |
diff --git a/app/helpers/node_actions_helper.rb b/app/helpers/node_actions_helper.rb index 53f6ecd0..019a9cf7 100644 --- a/app/helpers/node_actions_helper.rb +++ b/app/helpers/node_actions_helper.rb | |||
| @@ -19,10 +19,11 @@ module NodeActionsHelper | |||
| 19 | "otp_enroll" => "shield-lock", | 19 | "otp_enroll" => "shield-lock", |
| 20 | "otp_disable" => "shield-off", | 20 | "otp_disable" => "shield-off", |
| 21 | "otp_reset" => "shield-x", | 21 | "otp_reset" => "shield-x", |
| 22 | "user_create" => "user-plus", | ||
| 22 | "user_deactivate" => "user-off", | 23 | "user_deactivate" => "user-off", |
| 23 | "user_reactivate" => "user-check", | 24 | "user_reactivate" => "user-check", |
| 24 | "redaktion_grant" => "user-plus", | 25 | "redaktion_grant" => "users-plus", |
| 25 | "redaktion_revoke" => "user-minus" | 26 | "redaktion_revoke" => "users-minus" |
| 26 | }.freeze | 27 | }.freeze |
| 27 | 28 | ||
| 28 | def verb_icon action | 29 | def verb_icon action |
| @@ -295,4 +296,9 @@ module NodeActionsHelper | |||
| 295 | t("node_actions.redaktion_revoke", :actor => actor_ref(action), | 296 | t("node_actions.redaktion_revoke", :actor => actor_ref(action), |
| 296 | :target => user_participant_ref(action)).html_safe | 297 | :target => user_participant_ref(action)).html_safe |
| 297 | end | 298 | end |
| 299 | |||
| 300 | def summarize_user_create action | ||
| 301 | t("node_actions.user_create", :actor => actor_ref(action), | ||
| 302 | :target => user_participant_ref(action)).html_safe | ||
| 303 | end | ||
| 298 | end | 304 | end |
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 |
