Sha256: c7634d34f93fffc88c11fb02444e2f5b7f13572fc80f3d62034604672e2367b5

Contents?: true

Size: 1.25 KB

Versions: 86

Compression:

Stored size: 1.25 KB

Contents

module CoalescingPanda
  class LtiAccount < ActiveRecord::Base
    validates :name, :key, uniqueness: true
    validates :name, :key, :secret, presence: true
    has_many :lti_nonces, foreign_key: :coalescing_panda_lti_account_id, class_name: 'CoalescingPanda::LtiNonce'
    has_many :terms, foreign_key: :coalescing_panda_lti_account_id, class_name: 'CoalescingPanda::Term'
    has_many :courses, foreign_key: :coalescing_panda_lti_account_id, class_name: 'CoalescingPanda::Course'
    has_many :users, foreign_key: :coalescing_panda_lti_account_id, class_name: 'CoalescingPanda::User'
    has_many :canvas_batches, foreign_key: :coalescing_panda_lti_account_id, class_name: 'CoalescingPanda::CanvasBatch'
    has_many :sections, through: :courses
    has_many :enrollments, through: :sections
    has_many :assignments, through: :courses
    has_many :submissions, through: :assignments

    serialize :settings

    validates :canvas_account_id, presence: true

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

    private

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

  end
end

Version data entries

86 entries across 86 versions & 1 rubygems

Version Path
coalescing_panda-5.3.0 app/models/coalescing_panda/lti_account.rb
coalescing_panda-5.2.2 app/models/coalescing_panda/lti_account.rb
coalescing_panda-5.2.2.beta1 app/models/coalescing_panda/lti_account.rb
coalescing_panda-5.2.1 app/models/coalescing_panda/lti_account.rb
coalescing_panda-5.2.0 app/models/coalescing_panda/lti_account.rb
coalescing_panda-5.2.0.beta2 app/models/coalescing_panda/lti_account.rb
coalescing_panda-5.2.0.beta1 app/models/coalescing_panda/lti_account.rb
coalescing_panda-5.1.13 app/models/coalescing_panda/lti_account.rb
coalescing_panda-5.1.12 app/models/coalescing_panda/lti_account.rb
coalescing_panda-5.1.11 app/models/coalescing_panda/lti_account.rb
coalescing_panda-5.1.10 app/models/coalescing_panda/lti_account.rb
coalescing_panda-5.1.9 app/models/coalescing_panda/lti_account.rb
coalescing_panda-5.1.8 app/models/coalescing_panda/lti_account.rb
coalescing_panda-5.1.7 app/models/coalescing_panda/lti_account.rb
coalescing_panda-5.1.6 app/models/coalescing_panda/lti_account.rb
coalescing_panda-5.1.5 app/models/coalescing_panda/lti_account.rb
coalescing_panda-5.1.4 app/models/coalescing_panda/lti_account.rb
coalescing_panda-5.1.3.beta.2 app/models/coalescing_panda/lti_account.rb
coalescing_panda-5.1.3.beta.1 app/models/coalescing_panda/lti_account.rb
coalescing_panda-5.1.3 app/models/coalescing_panda/lti_account.rb