From c3d9c55b23183a51c941800d94ed0ff085e5a3b8 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 7 Oct 2015 15:46:18 -0400 Subject: Add gitlab:two_factor:disable_for_all_users task --- lib/tasks/gitlab/two_factor.rake | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 lib/tasks/gitlab/two_factor.rake (limited to 'lib/tasks') diff --git a/lib/tasks/gitlab/two_factor.rake b/lib/tasks/gitlab/two_factor.rake new file mode 100644 index 00000000000..acd4b7da39b --- /dev/null +++ b/lib/tasks/gitlab/two_factor.rake @@ -0,0 +1,10 @@ +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! + end + end + end +end -- cgit v1.2.1 From c8f18fc56283859f47ab50a5e14a7b292f8e54a5 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Wed, 7 Oct 2015 17:42:47 +0200 Subject: Added dedicated Rake task for setting up Postgres This ensures any PostgreSQL specific schema changes (e.g. expression indexes) are created when setting up the database. --- lib/tasks/gitlab/setup.rake | 1 + lib/tasks/migrate/setup_postgresql.rake | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 lib/tasks/migrate/setup_postgresql.rake (limited to 'lib/tasks') diff --git a/lib/tasks/gitlab/setup.rake b/lib/tasks/gitlab/setup.rake index 0ac4b0fa8a3..4cbccf2ca89 100644 --- a/lib/tasks/gitlab/setup.rake +++ b/lib/tasks/gitlab/setup.rake @@ -16,6 +16,7 @@ namespace :gitlab do Rake::Task["db:setup"].invoke Rake::Task["add_limits_mysql"].invoke + Rake::Task["setup_postgresql"].invoke Rake::Task["db:seed_fu"].invoke rescue Gitlab::TaskAbortedByUserError puts "Quitting...".red diff --git a/lib/tasks/migrate/setup_postgresql.rake b/lib/tasks/migrate/setup_postgresql.rake new file mode 100644 index 00000000000..bf6894a8351 --- /dev/null +++ b/lib/tasks/migrate/setup_postgresql.rake @@ -0,0 +1,6 @@ +require Rails.root.join('db/migrate/20151007120511_namespaces_projects_path_lower_indexes') + +desc 'GitLab | Sets up PostgreSQL' +task setup_postgresql: :environment do + NamespacesProjectsPathLowerIndexes.new.up +end -- cgit v1.2.1 From cd46f4c36736ed548e440566095e51a3a43ca6d6 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 8 Oct 2015 23:19:56 -0400 Subject: Add output and confirmation to gitlab:two_factor:disable_for_all_users --- lib/tasks/gitlab/two_factor.rake | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'lib/tasks') 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 -- cgit v1.2.1