capcoauth 0.3.2 → 0.3.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df5ff4301f9a840184240a23652d81b5cfceff9a
4
- data.tar.gz: 6409b7fefea4194a2552468783e83dbe6037d033
3
+ metadata.gz: 8ec44b77288ba8927780f0b45b3cb545d5268582
4
+ data.tar.gz: 57c2652a7fc0dc729d92496d82ccf3abf4aedac5
5
5
  SHA512:
6
- metadata.gz: 4aba21febd219d18ec7cc8e7e7d5a9f6875be5da5cf7764094237e147c9b1e70048347e8866f7e0c37018be0a12fceb3e12f8a12e33763ac9497bb28663d540e
7
- data.tar.gz: 033cc72215fe37ac75b3eca0ea9000070cdd933dba277877f82bee33c6450c008177135ecc31b81c2889a7ab2580853f319b6931ed72e8221868017c87d4ad7e
6
+ metadata.gz: 44933c8af8c9e94741dedbcb67577e6e06f2028134590be3b79f9915fbaa8907310dc4d70313758552232c2f8d5aaa801131b546b30af782b7739610a7c73ffa
7
+ data.tar.gz: 10206151a2418737ddac3147bfceba635237d30452bec9310b6793db2f463a1801962b4e7d0e193e72d1c5c34d682e203473d4186681e92b99841feabd68f43e
@@ -21,6 +21,9 @@ module Capcoauth
21
21
  # Set the user_id from the token response
22
22
  if response.code == 200
23
23
 
24
+ # Detect application credentials
25
+ application_credentials = response.parsed_response['resource_owner_id'].blank?
26
+
24
27
  # Get the proper ID value field from the response
25
28
  user_id_field = Capcoauth.configuration.user_id_field
26
29
  if user_id_field == :capcoauth
@@ -30,7 +33,7 @@ module Capcoauth
30
33
  end
31
34
 
32
35
  # Throw unauthorized if ID of specified type doesn't exist
33
- unless access_token.user_id
36
+ if access_token.user_id.blank? and !application_credentials
34
37
  logger.info("CapcOAuth: The access token for #{user_id_field} user ##{access_token.user_id} did not have an ID for type `#{user_id_field}`") unless logger.nil?
35
38
  raise UnauthorizedError
36
39
  end
@@ -43,6 +43,10 @@ module Capcoauth
43
43
  @current_user
44
44
  end
45
45
 
46
+ def capcoauth_token
47
+ @_capcoauth_token ||= OAuth::AccessToken.new(token_from_request)
48
+ end
49
+
46
50
  protected
47
51
 
48
52
  def handle_unauthorized
@@ -59,10 +63,6 @@ module Capcoauth
59
63
 
60
64
  private
61
65
 
62
- def capcoauth_token
63
- @_capcoauth_token ||= OAuth::AccessToken.new(token_from_request)
64
- end
65
-
66
66
  def token_from_request
67
67
  token_from_param || token_from_session || token_from_headers
68
68
  end
@@ -1,3 +1,3 @@
1
1
  module Capcoauth
2
- VERSION = '0.3.2'
2
+ VERSION = '0.3.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capcoauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Robertson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-21 00:00:00.000000000 Z
11
+ date: 2017-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties