Sha256: b7c7f86b998210ea9161c1460933ea45fd3e50d034a2a861c6f85c50051d9176

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

Contents

module LtiProvider
  module LtiApplication
    extend ActiveSupport::Concern

    module ClassMethods
    end

    included do
      before_action :require_lti_launch
    end

    protected
    def require_lti_launch
      if canvas_url.blank? || user_id.blank?
        reset_session
        prompt_for_launch
      end
    end

    def prompt_for_launch
      render plain: 'Please launch this tool from Canvas and then try again.'
    end

    def canvas_url
      session[:canvas_url]
    end

    def user_id
      session[:user_id]
    end

    def current_course_id
      session[:course_id]
    end

    def tool_consumer_instance_guid
      session[:tool_consumer_instance_guid]
    end

    def course_launch?
      current_course_id.present?
    end

    def current_account_id
      session[:account_id]
    end

    def account_launch?
      current_account_id.present?
    end

    def user_roles
      session[:user_roles]
    end

    def not_acceptable
      render plain: "Unable to process request", status: 406
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
lti_provider_engine-1.2.3 lib/lti_provider/lti_application.rb
lti_provider_engine-1.2.2 lib/lti_provider/lti_application.rb
lti_provider_engine-1.2.1 lib/lti_provider/lti_application.rb
lti_provider_engine-1.2.0 lib/lti_provider/lti_application.rb
qalam_lti_provider_engine-1.1.6 lib/lti_provider/lti_application.rb
lti_provider_engine-1.1.0 lib/lti_provider/lti_application.rb
lti_provider_engine-1.0.0 lib/lti_provider/lti_application.rb