From fefec929c59c72dc93e4be30e8f23cd8c5258b0a Mon Sep 17 00:00:00 2001 From: erdgeist Date: Fri, 24 Jul 2026 13:52:56 +0200 Subject: Add self-service TOTP enrollment UI and witnessed admin reset --- app/views/users/edit.html.erb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'app/views/users/edit.html.erb') diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 77b33c6a..8d14a058 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -30,4 +30,34 @@
<%= f.submit "Update" %>
<% end %> + + <% if @user == current_user %> +
Second factor
+
+ <% if current_user.otp_enrolled? %> +

Enabled.

+ <%= form_tag otp_enrollment_path, :method => :delete do %> + <%= password_field_tag :current_password, nil, :placeholder => "Current password" %> + <%= text_field_tag :code, nil, :placeholder => "Current code", + :autocomplete => "one-time-code", :inputmode => "numeric" %> + <%= submit_tag "Disable second factor" %> + <% end %> + <% else %> +

Not enrolled.

+ <%= form_tag otp_enrollment_path, :method => :post do %> + <%= password_field_tag :current_password, nil, :placeholder => "Current password" %> + <%= submit_tag "Enable second factor" %> + <% end %> + <% end %> +
+ <% elsif current_user.admin? && @user.otp_enrolled? %> +
Second factor
+
+ Enabled. + <%= button_to "Reset second factor", reset_otp_user_path(@user), :method => :put, + :form_class => "button_to destructive", + :form => { :data => { :confirm => + "Reset #{@user.login}'s second factor? They will log in with password only afterwards." } } %> +
+ <% end %> -- cgit v1.3