diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2015-10-09 08:04:34 +0000 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2015-10-09 08:04:34 +0000 |
commit | 6e1ec3b9affa298cba44078c18ae06d82950cffc (patch) | |
tree | 42d49d072d93304bd70845bb6fa08cb03e3f0dc4 /lib/tasks | |
parent | 6ba1e17c44f9567cd00591bcbabf75fe6786ebac (diff) | |
parent | cd46f4c36736ed548e440566095e51a3a43ca6d6 (diff) | |
download | gitlab-ce-6e1ec3b9affa298cba44078c18ae06d82950cffc.tar.gz |
Merge branch 'rs-2fa-task' into 'master'
Add task to disable 2FA for all users
Addresses #2971
See merge request !1532
Diffstat (limited to 'lib/tasks')
-rw-r--r-- | lib/tasks/gitlab/two_factor.rake | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/two_factor.rake b/lib/tasks/gitlab/two_factor.rake new file mode 100644 index 00000000000..9196677a017 --- /dev/null +++ b/lib/tasks/gitlab/two_factor.rake @@ -0,0 +1,23 @@ +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.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 |