Sha256: 5725fe28d36d0e297fadb1389f17335c66bf0624238a3a84144c19440791f42f

Contents?: true

Size: 746 Bytes

Versions: 4

Compression:

Stored size: 746 Bytes

Contents

module CoalescingPanda
  class LtiAccount < ActiveRecord::Base
    validates :name, :key, uniqueness: true
    validates :name, :key, :secret, presence: true
    has_many :coalescing_panda_lti_nonces,
             :foreign_key => :coalescing_panda_lti_account_id,
             :class_name => 'CoalescingPanda::LtiNonce'

    attr_accessible :name, :key, :secret, :oauth2_client_id, :oauth2_client_key

    def validate_nonce(nonce, timestamp)
      cleanup_nonce
      if timestamp > 15.minutes.ago
        coalescing_panda_lti_nonces.create(nonce: nonce, timestamp: timestamp).persisted?
      end
    end

    private

    def cleanup_nonce
      coalescing_panda_lti_nonces.where('timestamp > ?', 15.minutes.ago).delete_all
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
coalescing_panda-1.1.5 app/models/coalescing_panda/lti_account.rb
coalescing_panda-1.1.3 app/models/coalescing_panda/lti_account.rb
coalescing_panda-1.1.0 app/models/coalescing_panda/lti_account.rb
coalescing_panda-1.0.9 app/models/coalescing_panda/lti_account.rb