mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
Added admin:create rake task
This commit is contained in:
parent
6a6496eedf
commit
cb3b79407d
3 changed files with 25 additions and 0 deletions
1
Gemfile
1
Gemfile
|
@ -65,6 +65,7 @@ gem 'strong_parameters' # remove when we upgrade to Rails 4
|
||||||
gem 'therubyracer', require: 'v8'
|
gem 'therubyracer', require: 'v8'
|
||||||
gem 'thin'
|
gem 'thin'
|
||||||
gem 'diffy', require: false
|
gem 'diffy', require: false
|
||||||
|
gem 'highline', require: false
|
||||||
|
|
||||||
# Gem that enables support for plugins. It is required.
|
# Gem that enables support for plugins. It is required.
|
||||||
gem 'discourse_plugin', path: 'vendor/gems/discourse_plugin'
|
gem 'discourse_plugin', path: 'vendor/gems/discourse_plugin'
|
||||||
|
|
|
@ -503,6 +503,7 @@ DEPENDENCIES
|
||||||
guard-rspec
|
guard-rspec
|
||||||
guard-spork
|
guard-spork
|
||||||
has_ip_address
|
has_ip_address
|
||||||
|
highline
|
||||||
hiredis
|
hiredis
|
||||||
image_optim
|
image_optim
|
||||||
image_sorcery
|
image_sorcery
|
||||||
|
|
23
lib/tasks/admin.rake
Normal file
23
lib/tasks/admin.rake
Normal file
|
@ -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
|
Loading…
Reference in a new issue