Sha256: 516715eeaa20595114ddacd3bdfcbbcd3682e96b993de53a27397a08a4bc2f0f
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
module CanvasOauth class CanvasController < CanvasOauth::OauthApplicationController skip_before_action :request_canvas_authentication def oauth if verify_oauth2_state(params[:state]) && params[:code] if token = canvas.get_access_token(params[:code]) set_root_account refresh_token = canvas.refresh_token if CanvasOauth::Authorization.cache_token(token, refresh_token, user_id, @root_account_id, tool_consumer_instance_guid) redirect_to main_app.root_path else render plain: "Error: unable to save token" end else render plain: "Error: invalid code - #{params[:code]}" end else render plain: "#{CanvasOauth::Config.tool_name} needs access to your account in order to function properly. Please try again and click log in to approve the integration." end end def verify_oauth2_state(callback_state) callback_state.present? && callback_state == session.delete(:oauth2_state) end end def set_root_account if current_account_id @root_account_id = canvas.root_account_id(current_account_id) elsif current_course_id @root_account_id = canvas.course_root_account_id(current_course_id) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
qalam_oauth_engine-3.0.5 | app/controllers/canvas_oauth/canvas_controller.rb |
qalam_oauth_engine-3.0.4 | app/controllers/canvas_oauth/canvas_controller.rb |