Commit c23ca24

mo <mo.khan@gmail.com>
2018-09-04 22:04:16
include flash notice when disabling MFA.
1 parent 66c3d2e
Changed files (3)
app
controllers
views
spec
requests
app/controllers/my/mfas_controller.rb
@@ -20,7 +20,7 @@ module My
 
     def destroy
       current_user.tfa.disable!
-      redirect_to my_dashboard_path
+      redirect_to my_dashboard_path, notice: 'MFA has been disabled'
     end
   end
 end
app/views/my/mfas/edit.html.erb
@@ -1,13 +1,13 @@
 <div class="container">
   <div class="row">
     <div class="col">
-      <h1>Two Factor Authentication (TFA)</h1>
+      <h1>Multi-Factor Authentication (MFA)</h1>
       <div data-controller="tfa--setup">
         <canvas id="canvas" data-target="tfa--setup.canvas"></canvas>
         <p>Secret: <%= current_user.tfa.secret %></p>
         <p>Provisioning URI: <%= current_user.tfa.provisioning_uri %></p>
 
-        <%= form_for current_user, url: tfa_path, method: :delete do |form| %>
+        <%= form_for current_user, url: my_mfa_path, method: :delete do |form| %>
           <%= form.hidden_field :tfa_secret, data: { target: 'tfa--setup.secret' } %>
           <%= form.submit "Disable", class: 'btn btn-danger', data: { disable_with: 'Saving…' } %>
           <%= link_to "Cancel", my_dashboard_path, class: 'btn' %>
spec/requests/my/mfas_spec.rb
@@ -54,6 +54,7 @@ RSpec.describe '/my/mfa' do
 
         specify { expect(current_user.reload.tfa_secret).to be_nil }
         specify { expect(response).to redirect_to(my_dashboard_path) }
+        specify { expect(flash[:notice]).to include("MFA has been disabled") }
       end
     end
   end