Merge pull request #158 from colibri-software/add_admin_user

Added rake task to create new admin user
This commit is contained in:
Didier Lafforgue 2011-08-14 12:27:03 -07:00
commit b4bfea616a
3 changed files with 19 additions and 0 deletions

View File

@ -41,6 +41,8 @@ gem 'locomotive_jammit-s3', :require => 'jammit-s3'
gem 'SystemTimer', :platforms => :ruby_18
gem 'cells'
gem 'highline'
# The rest of the dependencies are for use when in the locomotive dev environment
group :development do

View File

@ -309,6 +309,7 @@ DEPENDENCIES
growl-glue
haml (= 3.1.2)
heroku (= 1.19.1)
highline
httparty (>= 0.6.1)
inherited_resources (~> 1.1.2)
launchy

View File

@ -1,6 +1,7 @@
# encoding: utf-8
require 'locomotive'
require 'highline/import'
namespace :locomotive do
@ -45,6 +46,21 @@ namespace :locomotive do
::Locomotive::Import::Job.run!(url, site, { :samples => true, :reset => reset })
end
desc 'Add a new admin user (NOTE: currently only supports adding user to first site)'
task :add_admin => :environment do
name = ask('Display name: ') { |q| q.echo = true }
email = ask('Email address: ') { |q| q.echo = true }
password = ask('Password: ') { |q| q.echo = '*' }
password_confirm = ask('Confirm password: ') { |q| q.echo = '*' }
account = Account.create :email => email, :password => password, :password_confirmation => password_confirm, :name => name
# TODO: this should be changed to work for multi-sites (see desc)
site = Site.first
site.memberships.build :account => account, :role => 'admin'
site.save!
end
namespace :upgrade do
desc 'Set roles to the existing users'