summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-10-08 23:19:56 -0400
committerRobert Speicher <rspeicher@gmail.com>2015-10-08 23:19:56 -0400
commitcd46f4c36736ed548e440566095e51a3a43ca6d6 (patch)
tree0dee03cb356c5a35b9260e699dfb7413d7d4bfce
parent5a28a5b72634ba180180dfeaeca1d2b0d988e177 (diff)
downloadgitlab-ce-cd46f4c36736ed548e440566095e51a3a43ca6d6.tar.gz
Add output and confirmation to gitlab:two_factor:disable_for_all_usersrs-2fa-task
-rw-r--r--lib/tasks/gitlab/two_factor.rake17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/tasks/gitlab/two_factor.rake b/lib/tasks/gitlab/two_factor.rake
index acd4b7da39b..9196677a017 100644
--- a/lib/tasks/gitlab/two_factor.rake
+++ b/lib/tasks/gitlab/two_factor.rake
@@ -2,8 +2,21 @@ namespace :gitlab do
namespace :two_factor do
desc "GitLab | Disable Two-factor authentication (2FA) for all users"
task disable_for_all_users: :environment do
- User.with_two_factor.find_each do |user|
- user.disable_two_factor!
+ scope = User.with_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