Sha256: d2b6b8cf7fe64fdfe91af55c8696ef563bd2717b4a90e625540090f9283bd8f9
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
namespace :authengine do desc 'create an admin access account, only when there are no accounts already configured. Call rake authengine:bootstrap[firstname,lastname,login,password] (no spaces, no quotes)' task :bootstrap, [:firstName, :lastName, :login, :password] => :environment do |t, args| if args.to_hash.keys.length < 4 puts "Please specify firstname, lastname, login and password" else if User.count > 0 puts "There is already a user account present, you may only bootstrap the first account" else attributes = {:firstName => args[:firstName], :lastName => args[:lastName], :login => args[:login], :password => args[:password], :password_confirmation => args[:password]} if id = User.create_by_sql(attributes) puts "Creating account for #{attributes[:firstName]} #{attributes[:lastName]} login: #{attributes[:login]}, password #{attributes[:password]}" end end end if user = User.find(id) role = Role.create(:name => 'admin') user.roles << role Controller.update_table ActionRole.bootstrap_access_for(role) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
authengine-0.0.2 | lib/tasks/bootstrap.rake |