Sha256: 331e7f93d394ced69802af2eb7a3ec28547c0373d0b76600778d898f6a7329b0

Contents?: true

Size: 654 Bytes

Versions: 6

Compression:

Stored size: 654 Bytes

Contents

module ForemanVirtWhoConfigure
  # holds the encrypted password for internal user that can be deployed to virt who reporter
  class ServiceUser < ApplicationRecord
    include Authorizable
    include Encryptable
    encrypts :encrypted_password

    belongs_to :user
    has_many :configs, :inverse_of => :service_user

    # Foreman 1.11 specifics, can be removed later, otherwise when string does not start with "encrypts" prefix
    # we get 500 when we try to create log message that relies on name method
    def name
      username || to_s
    end

    def username
      User.as_anonymous_admin do
        user&.login
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
foreman_virt_who_configure-0.5.25 app/models/foreman_virt_who_configure/service_user.rb
foreman_virt_who_configure-0.5.24 app/models/foreman_virt_who_configure/service_user.rb
foreman_virt_who_configure-0.5.23 app/models/foreman_virt_who_configure/service_user.rb
foreman_virt_who_configure-0.5.21 app/models/foreman_virt_who_configure/service_user.rb
foreman_virt_who_configure-0.5.20 app/models/foreman_virt_who_configure/service_user.rb
foreman_virt_who_configure-0.5.19 app/models/foreman_virt_who_configure/service_user.rb