From 71a1d75d7e211cf0f156fdb443fc00b5bd1e0621 Mon Sep 17 00:00:00 2001 From: Jay Pfaffman Date: Fri, 10 Aug 2018 14:45:40 -0700 Subject: [PATCH] FIX: disable_2fa fix method selection The previous code resulted in NameError: undefined local variable or method `totp' for main:Object I now understand what @tgxworld meant about we should only disable totp when I submitted this before. This is the kind of Ruby stuff that I still don't understand well,(perhaps this isn't the most Ruby way to do this?) but this does what I think is supposed to happen. And it worked just now. --- lib/tasks/users.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/users.rake b/lib/tasks/users.rake index 7ea7f24c2a4..9bfaa79c9cd 100644 --- a/lib/tasks/users.rake +++ b/lib/tasks/users.rake @@ -143,7 +143,7 @@ desc "Disable 2FA for user with the given username" task "users:disable_2fa", [:username] => [:environment] do |_, args| username = args[:username] user = find_user(username) - UserSecondFactor.totp.where(user_id: user.id).each(&:destroy!) + UserSecondFactor.where(user_id: user.id, method: UserSecondFactor.methods[:totp]).each(&:destroy!) puts "2FA disabled for #{username}" end