Class: AtomicLti1v1::Nonce
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- AtomicLti1v1::Nonce
- Defined in:
- app/models/atomic_lti1v1/nonce.rb
Class Method Summary collapse
-
.clean ⇒ Object
Remove old nonces from db.
- .valid?(nonce) ⇒ Boolean
Class Method Details
.clean ⇒ Object
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
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 |