debian-mirror-gitlab/lib/tasks/gitlab/two_factor.rake

24 lines
709 B
Ruby
Raw Normal View History

2015-10-24 18:46:33 +05:30
namespace :gitlab do
namespace :two_factor do
desc "GitLab | Disable Two-factor authentication (2FA) for all users"
task disable_for_all_users: :environment do
scope = User.with_two_factor
count = scope.count
if count > 0
puts "This will disable 2FA for #{count.to_s.color(:red)} users..."
2015-10-24 18:46:33 +05:30
begin
ask_to_continue
scope.find_each(&:disable_two_factor!)
puts "Successfully disabled 2FA for #{count} users.".color(:green)
2015-10-24 18:46:33 +05:30
rescue Gitlab::TaskAbortedByUserError
puts "Quitting...".color(:red)
2015-10-24 18:46:33 +05:30
end
else
puts "There are currently no users with 2FA enabled.".color(:yellow)
2015-10-24 18:46:33 +05:30
end
end
end
end