Commit cd46f4c3 authored by Robert Speicher's avatar Robert Speicher

Add output and confirmation to gitlab:two_factor:disable_for_all_users

parent 5a28a5b7
...@@ -2,8 +2,21 @@ namespace :gitlab do ...@@ -2,8 +2,21 @@ namespace :gitlab do
namespace :two_factor do namespace :two_factor do
desc "GitLab | Disable Two-factor authentication (2FA) for all users" desc "GitLab | Disable Two-factor authentication (2FA) for all users"
task disable_for_all_users: :environment do task disable_for_all_users: :environment do
User.with_two_factor.find_each do |user| scope = User.with_two_factor
user.disable_two_factor! count = scope.count
if count > 0
puts "This will disable 2FA for #{count.to_s.red} users..."
begin
ask_to_continue
scope.find_each(&:disable_two_factor!)
puts "Successfully disabled 2FA for #{count} users.".green
rescue Gitlab::TaskAbortedByUserError
puts "Quitting...".red
end
else
puts "There are currently no users with 2FA enabled.".yellow
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment