diff --git a/Gemfile b/Gemfile index bb147414f1d..20fb0ec67e4 100644 --- a/Gemfile +++ b/Gemfile @@ -65,6 +65,7 @@ gem 'strong_parameters' # remove when we upgrade to Rails 4 gem 'therubyracer', require: 'v8' gem 'thin' gem 'diffy', require: false +gem 'highline', require: false # Gem that enables support for plugins. It is required. gem 'discourse_plugin', path: 'vendor/gems/discourse_plugin' diff --git a/Gemfile.lock b/Gemfile.lock index c3bb60784ee..3460302fe69 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -503,6 +503,7 @@ DEPENDENCIES guard-rspec guard-spork has_ip_address + highline hiredis image_optim image_sorcery diff --git a/lib/tasks/admin.rake b/lib/tasks/admin.rake new file mode 100644 index 00000000000..0579fb35573 --- /dev/null +++ b/lib/tasks/admin.rake @@ -0,0 +1,23 @@ +desc "Creates a forum administrator" +task "admin:create" => :environment do + require 'highline/import' + begin + admin = User.new + admin.email = ask("Email:") + admin.username = "admin" + begin + password = ask("Password:") {|q| q.echo = false} + password_confirmation = ask("Repeat password:") {|q| q.echo = false} + end while password != password_confirmation + admin.password = password + # admin.email_confirmed = true + saved = admin.save + if !saved + puts admin.errors.full_messages.join("\n") + next + end + end while !saved + admin.grant_admin! + admin.change_trust_level!(TrustLevel.levels.max_by{|k, v| v}[0]) + admin.email_tokens.update_all confirmed: true +end