about summary refs log tree commit diff
path: root/app/controllers
diff options
context:
space:
mode:
authorkibigo! <marrus-sh@users.noreply.github.com>2017-08-01 13:07:43 -0700
committerkibigo! <marrus-sh@users.noreply.github.com>2017-08-01 13:20:29 -0700
commit8150689b48716bb016d492d28cef08600a4b315e (patch)
treea05a2539e894c79ef17698dce0da5a6af0c25bf6 /app/controllers
parentb61e3daf983d87c6d2de7e54d420c2e8f5a531e6 (diff)
parent7ef848256871454a790a9b7cc725053c67ba3da4 (diff)
Merge upstream (#111)
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/settings/two_factor_authentications_controller.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/controllers/settings/two_factor_authentications_controller.rb b/app/controllers/settings/two_factor_authentications_controller.rb
index 983483881..863cc7351 100644
--- a/app/controllers/settings/two_factor_authentications_controller.rb
+++ b/app/controllers/settings/two_factor_authentications_controller.rb
@@ -18,7 +18,7 @@ module Settings
     end
 
     def destroy
-      if current_user.validate_and_consume_otp!(confirmation_params[:code])
+      if acceptable_code?
         current_user.otp_required_for_login = false
         current_user.save!
         redirect_to settings_two_factor_authentication_path
@@ -38,5 +38,10 @@ module Settings
     def verify_otp_required
       redirect_to settings_two_factor_authentication_path if current_user.otp_required_for_login?
     end
+
+    def acceptable_code?
+      current_user.validate_and_consume_otp!(confirmation_params[:code]) ||
+        current_user.invalidate_otp_backup_code!(confirmation_params[:code])
+    end
   end
 end