coalescing_panda 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
@@ -3,16 +3,20 @@ module CoalescingPanda
|
|
3
3
|
|
4
4
|
def canvas_oauth2
|
5
5
|
user_id = params['user_id']
|
6
|
+
uri = URI.parse(params['launch_presentation_return_url'])
|
7
|
+
api_domain = uri.host
|
8
|
+
api_domain = "#{api_domain}:#{uri.port.to_s}" if uri.port
|
9
|
+
scheme = uri.scheme + '://'
|
6
10
|
|
7
|
-
if token = CanvasApiAuth.where('user_id = ? and api_domain = ?', user_id,
|
8
|
-
@client = Bearcat::Client.new(token: token, prefix:
|
11
|
+
if token = CanvasApiAuth.where('user_id = ? and api_domain = ?', user_id, api_domain).pluck(:api_token).first
|
12
|
+
@client = Bearcat::Client.new(token: token, prefix: scheme+api_domain)
|
9
13
|
elsif @lti_account = params['oauth_consumer_key'] && LtiAccount.find_by_key(params['oauth_consumer_key'])
|
10
14
|
client_id = @lti_account.oauth2_client_id
|
11
|
-
client = Bearcat::Client.new(prefix:
|
15
|
+
client = Bearcat::Client.new(prefix: scheme+api_domain)
|
12
16
|
@lti_params = params.to_hash
|
13
17
|
@canvas_url = client.auth_redirect_url(client_id,
|
14
18
|
coalescing_panda.oauth2_redirect_url({key: params['oauth_consumer_key'],
|
15
|
-
user_id: user_id, api_domain:
|
19
|
+
user_id: user_id, api_domain: api_domain}))
|
16
20
|
#delete the added params so the original oauth sig still works
|
17
21
|
@lti_params.delete('action')
|
18
22
|
@lti_params.delete('controller')
|
@@ -64,10 +68,8 @@ module CoalescingPanda
|
|
64
68
|
:test
|
65
69
|
when /(localhost)|(127\.0\.0\.1).*/
|
66
70
|
:dev
|
67
|
-
when /https:\/\/.*/
|
68
|
-
:production
|
69
71
|
else
|
70
|
-
:
|
72
|
+
:production
|
71
73
|
end
|
72
74
|
end
|
73
75
|
|