From 7880671f3527b80de891053beaeae4a8a22c8c58 Mon Sep 17 00:00:00 2001 From: Kaylee Date: Tue, 2 May 2017 20:07:12 +0100 Subject: Add option to disable two factor auth in admin accounts panel. (#2584) * Add option to disable two factor auth in admin accounts panel. Closes #2578 * Add @mjankowski's suggestions. * Moves destroy actions behind User#disable_two_factor! * Adds spec coverage for Admin:TwoFactorAuthenticationsController and User#disable_two_factor! --- app/models/user.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app/models') diff --git a/app/models/user.rb b/app/models/user.rb index f6e080d4e..f8e8a2efa 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -56,6 +56,12 @@ class User < ApplicationRecord confirmed_at.present? end + def disable_two_factor! + self.otp_required_for_login = false + otp_backup_codes&.clear + save! + end + def send_devise_notification(notification, *args) devise_mailer.send(notification, self, *args).deliver_later end -- cgit