Module: Locomotive::Concerns::Account::ApiKey

Extended by:
ActiveSupport::Concern
Included in:
Account
Defined in:
app/models/locomotive/concerns/account/api_key.rb

Overview

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#regenerate_api_keyString

Regenerate the API key without saving the account.

Returns:

  • (String)

    The new api key



24
25
26
# File 'app/models/locomotive/concerns/account/api_key.rb', line 24

def regenerate_api_key
  self.api_key = Digest::SHA1.hexdigest("#{self._id}-#{Time.now.to_f}-#{self.created_at}")
end

#regenerate_api_key!Object

Regenerate the API key AND then save the account.



30
31
32
33
# File 'app/models/locomotive/concerns/account/api_key.rb', line 30

def regenerate_api_key!
  self.regenerate_api_key
  self.save
end