Class: LtiBoxEngine::LtiLaunch

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/lti_box_engine/lti_launch.rb

Class Method Summary collapse

Class Method Details

.cleanup!(num_days = 3) ⇒ Object



11
12
13
# File 'app/models/lti_box_engine/lti_launch.rb', line 11

def cleanup!(num_days=3)
  where("request_oauth_timestamp <= ?", Time.now - num_days.days).destroy_all
end

.create_from_tp(tp) ⇒ Object



15
16
17
18
19
20
21
# File 'app/models/lti_box_engine/lti_launch.rb', line 15

def create_from_tp(tp)
  create({
    nonce: tp.request_oauth_nonce,
    request_oauth_timestamp: Time.at(tp.request_oauth_timestamp.to_i),
    payload: tp.to_params
  })
end

.valid_nonce?(nonce, min = 60) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
# File 'app/models/lti_box_engine/lti_launch.rb', line 6

def valid_nonce?(nonce, min=60)
  nonce_ts = Time.now - (min * 60 * 60)
  where(nonce: nonce).where("request_oauth_timestamp >= ?", nonce_ts).count == 0
end