Class: LtiProvider::LtiController
- Inherits:
-
LtiApplicationController
- Object
- ActionController::Base
- LtiApplicationController
- LtiProvider::LtiController
- Defined in:
- app/controllers/lti_provider/lti_controller.rb
Instance Method Summary collapse
Instance Method Details
#configure ⇒ Object
48 49 50 51 52 53 54 |
# File 'app/controllers/lti_provider/lti_controller.rb', line 48 def configure respond_to do |format| format.xml do render xml: Launch.xml_config(lti_launch_url) end end end |
#consume_launch ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/lti_provider/lti_controller.rb', line 31 def consume_launch launch = Launch.where("created_at > ?", 5.minutes.ago).find_by_nonce(params[:nonce]) if launch [:account_id, :course_name, :course_id, :canvas_url, :tool_consumer_instance_guid, :user_id, :user_name, :user_roles, :user_avatar_url].each do |attribute| session[attribute] = launch.public_send(attribute) end launch.destroy redirect_to main_app.root_path else return show_error "The tool was not launched successfully. Please try again." end end |
#cookie_test ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'app/controllers/lti_provider/lti_controller.rb', line 22 def if session[:cookie_test] # success!!! we've got a session! consume_launch else render end end |
#launch ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/lti_provider/lti_controller.rb', line 7 def launch provider = IMS::LTI::ToolProvider.new(params['oauth_consumer_key'], LtiProvider::Config.secret, params) launch = Launch.initialize_from_request(provider, request) if !launch.valid_provider? msg = "#{launch.lti_errormsg} Please be sure you are launching this tool from the link provided in Canvas." return show_error msg elsif launch.save session[:cookie_test] = true redirect_to (nonce: launch.nonce) else return show_error "Unable to launch #{LtiProvider::XmlConfig.tool_title}. Please check your External Tools configuration and try again." end end |