Sha256: 48e6b086ee3366b63de094d9a1d0b5f77fdc68e4997aceb70319bf7bc8a8ef4d

Contents?: true

Size: 728 Bytes

Versions: 5

Compression:

Stored size: 728 Bytes

Contents

namespace :permissions do
  desc 'Reset Administrator user permissions to defaults'
  task :reset => :environment do
    unless Facter.domain.nil?
      user = User.find_or_create_by_login(:login => "admin", :firstname => "Admin", :lastname => "User", :mail => "root@#{Facter.domain}")
      user.update_attribute :admin, true
      src  = AuthSourceInternal.find_or_create_by_type "AuthSourceInternal"
      src.update_attribute :name, "Internal"
      user.auth_source = src
      user.password="changeme"
      if user.save
        puts "Reset to user:admin, password:changeme"
      else
        puts user.errors.full_messages.join(", ")
      end
    else
      fail "The domain of this host is not set."
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_discovery-1.0.0 test/foreman_app/lib/tasks/reset_permissions.rake
foreman_discovery-1.0.0.rc4 test/foreman_app/lib/tasks/reset_permissions.rake
foreman_discovery-1.0.0.rc3 test/foreman_app/lib/tasks/reset_permissions.rake
foreman_discovery-1.0.0.rc2 test/foreman_app/lib/tasks/reset_permissions.rake
foreman_discovery-1.0.0.rc1 test/foreman_app/lib/tasks/reset_permissions.rake