Sha256: f1a9f476ccdb9235c39ae9596e231f670291fdc12f57d97ddf5f86d1ac8638f0

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

require 'securerandom'

namespace :caseadilla do

  namespace :users do

    desc "Create default admin user"
    task create_admin: :environment do

      raise "Usage: specify email address, e.g. rake [task] email=mail@caseadillacms.com" unless ENV.include?("email")

      random_password = random_string = SecureRandom.hex
      admin = Caseadilla::AdminUser.new({ login: 'admin', name: 'Admin', email: ENV['email'], access_level: $CASEIN_USER_ACCESS_LEVEL_ADMIN, password: random_password, password_confirmation: random_password })

      unless admin.save
        puts "[Caseadilla] Failed: check that the 'admin' account doesn't already exist."
      else
        puts "[Caseadilla] Created new admin user with username 'admin' and password '#{random_password}'"
      end
    end

    desc "Remove all users"
    task remove_all: :environment do
      users = Caseadilla::AdminUser.all
      num_users = users.size
      users.destroy_all
      puts "[Caseadilla] Removed #{num_users} user(s)"
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caseadilla-0.0.1 lib/railties/tasks.rake