diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-31 17:05:05 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-31 17:05:05 +0200 |
| commit | 8c6a6516e1dc5c1b4f12740a6f7b32765b530bb7 (patch) | |
| tree | e40a1da656bedef0662f0e984b4e3b00b374bc1d /app/views/users | |
| parent | 464dd4266bdc433805010b5dca428f4cb75c2a81 (diff) | |
Replace user deletion with deactivation
Deactivation adds the alumni role and leaves the others in place, so
reactivation is lossless and nobody has to remember what an account held.
login_from_session checks alumni? on every request, so a signed-in user is
locked out on their next one without any session invalidation. Guards
prevent deactivating yourself or the last active admin, and both verbs are
witnessed in the action log.
Diffstat (limited to 'app/views/users')
| -rw-r--r-- | app/views/users/_user.html.erb | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/app/views/users/_user.html.erb b/app/views/users/_user.html.erb index 04884be8..ff9d4e37 100644 --- a/app/views/users/_user.html.erb +++ b/app/views/users/_user.html.erb | |||
| @@ -9,14 +9,22 @@ | |||
| 9 | <% end %> | 9 | <% end %> |
| 10 | </td> | 10 | </td> |
| 11 | <td><%= link_to t("admin.common.show"), user_path(user) %></td> | 11 | <td><%= link_to t("admin.common.show"), user_path(user) %></td> |
| 12 | <% if current_user.admin? || current_user == user %> | ||
| 13 | <td><%= link_to t("admin.common.edit"), edit_user_path(user) %></td> | ||
| 14 | <td> | 12 | <td> |
| 15 | <%= button_to user_path(user), method: :delete, | 13 | <% if current_user.admin? || current_user == user %> |
| 16 | form: { data: { confirm: t(".confirm_destroy", :login => user.login) }, class: 'button_to destructive' } do %> | 14 | <%= link_to t("admin.common.edit"), edit_user_path(user) %> |
| 17 | <%= icon("trash", library: "tabler", "aria-hidden": true) %> <%= t("admin.common.destroy") %> | 15 | <% end %> |
| 18 | <% end %> | 16 | </td> |
| 17 | <td> | ||
| 18 | <% if current_user.admin? && current_user != user %> | ||
| 19 | <% if user.alumni? %> | ||
| 20 | <%= button_to t(".reactivate"), reactivate_user_path(user), method: :put, | ||
| 21 | form: { class: 'button_to state_changing' } %> | ||
| 22 | <% else %> | ||
| 23 | <%= button_to t(".deactivate"), deactivate_user_path(user), method: :put, | ||
| 24 | form: { data: { confirm: t(".confirm_deactivate", :login => user.login) }, | ||
| 25 | class: 'button_to destructive' } %> | ||
| 26 | <% end %> | ||
| 27 | <% end %> | ||
| 19 | </td> | 28 | </td> |
| 20 | <% end %> | ||
| 21 | </tr> | 29 | </tr> |
| 22 | <% end %> | 30 | <% end %> |
