Class: LtiBoxEngine::LtiLaunch
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- LtiBoxEngine::LtiLaunch
- Defined in:
- app/models/lti_box_engine/lti_launch.rb
Class Method Summary collapse
- .cleanup!(num_days = 3) ⇒ Object
- .create_from_tp(tp) ⇒ Object
- .get_user_for_lti_launch(tp) ⇒ Object
- .valid_nonce?(nonce, min = 60) ⇒ Boolean
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..to_i), payload: tp.to_params }) end |
.get_user_for_lti_launch(tp) ⇒ Object
23 24 25 |
# File 'app/models/lti_box_engine/lti_launch.rb', line 23 def get_user_for_lti_launch(tp) User.where(lti_id: tp.user_id, tool_consumer_instance_guid: tp.tool_consumer_instance_guid) end |
.valid_nonce?(nonce, min = 60) ⇒ 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 |