about summary refs log tree commit diff
path: root/app/controllers/settings/two_factor_authentication
diff options
context:
space:
mode:
authorAboobacker MK <aboobacker@redpanthers.co>2018-01-21 17:51:28 +0530
committerEugen Rochko <eugen@zeonfederated.com>2018-01-21 13:21:28 +0100
commit112b1fa265f650c01eef2578e286214e3d82dcac (patch)
tree10dc6800e8112184e684114ebf77478dedb49557 /app/controllers/settings/two_factor_authentication
parent31d148588737e5e5dc8aada7913884f226831fd1 (diff)
Redirect to 2FA creation page when otp_secret is not available (#6314)
Diffstat (limited to 'app/controllers/settings/two_factor_authentication')
-rw-r--r--app/controllers/settings/two_factor_authentication/confirmations_controller.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/app/controllers/settings/two_factor_authentication/confirmations_controller.rb b/app/controllers/settings/two_factor_authentication/confirmations_controller.rb
index 4cf62db13..8d534960d 100644
--- a/app/controllers/settings/two_factor_authentication/confirmations_controller.rb
+++ b/app/controllers/settings/two_factor_authentication/confirmations_controller.rb
@@ -6,6 +6,7 @@ module Settings
       layout 'admin'
 
       before_action :authenticate_user!
+      before_action :ensure_otp_secret
 
       def new
         prepare_two_factor_form
@@ -38,6 +39,10 @@ module Settings
         @provision_url = current_user.otp_provisioning_uri(current_user.email, issuer: Rails.configuration.x.local_domain)
         @qrcode = RQRCode::QRCode.new(@provision_url)
       end
+
+      def ensure_otp_secret
+        redirect_to settings_two_factor_authentication_path unless current_user.otp_secret
+      end
     end
   end
 end