Class: ForemanOpentofu::Token

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/foreman_opentofu/token.rb

Instance Method Summary collapse

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'app/models/foreman_opentofu/token.rb', line 5

def expired?
  !expire.respond_to?(:<=) || (expire <= Time.current)
end

#generateObject



9
10
11
12
13
14
# File 'app/models/foreman_opentofu/token.rb', line 9

def generate
  self.expire = Time.current + Setting[:tfstate_token_timeout]
  self.token = SecureRandom.alphanumeric(255)
  save!
  token
end