Class: AtomicLti1v1::Nonce

Inherits:
ApplicationRecord show all
Defined in:
app/models/atomic_lti1v1/nonce.rb

Class Method Summary collapse

Class Method Details

.cleanObject

Remove old nonces from db. Run this from a background task to clean the db of extraneous data.



13
14
15
# File 'app/models/atomic_lti1v1/nonce.rb', line 13

def self.clean
  delete_all(['created_at < ?', Time.now - 6.hours])
end

.valid?(nonce) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
# File 'app/models/atomic_lti1v1/nonce.rb', line 3

def self.valid?(nonce)
  create!(nonce: nonce)
  true
rescue ActiveRecord::RecordNotUnique => e
  Rails.logger.warn("Failed to create nonce: #{nonce}")
  false
end