Sha256: e1ff722ace154bf38a9b2e87d543b2b58226d30413fe25c846e3ef5f4116f8b1

Contents?: true

Size: 1021 Bytes

Versions: 7

Compression:

Stored size: 1021 Bytes

Contents

require 'authlogic'
require 'securerandom'

namespace :casein 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@caseincms.com [(optional) password=mypassword]" unless ENV.include?("email")
      password = ENV['password'] || SecureRandom.hex
      admin = Casein::AdminUser.new({ login: 'admin', name: 'Admin', email: ENV['email'], access_level: $CASEIN_USER_ACCESS_LEVEL_ADMIN, password: password, password_confirmation: password })

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

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

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
casein-5.1.1.5 lib/railties/tasks.rake
casein-5.1.1.4 lib/railties/tasks.rake
casein-5.1.1.3 lib/railties/tasks.rake
casein-5.1.1.2 lib/railties/tasks.rake
casein-5.1.1.1 lib/railties/tasks.rake
casein-5.1.1.0 lib/railties/tasks.rake
casein-5.1.0.0 lib/railties/tasks.rake