coalescing_panda 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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, request.host).pluck(:api_token).first
8
- @client = Bearcat::Client.new(token: token, prefix: request.host)
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: request.host)
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: request.host}))
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
- :unknown
72
+ :production
71
73
  end
72
74
  end
73
75
 
@@ -1,3 +1,3 @@
1
1
  module CoalescingPanda
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coalescing_panda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: