devise_oauth2_providable 0.2.1 → 0.2.2
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.
@@ -8,9 +8,8 @@ module Devise
|
|
8
8
|
@req.oauth2?
|
9
9
|
end
|
10
10
|
def authenticate!
|
11
|
-
token =
|
12
|
-
|
13
|
-
resource = access_token ? access_token.user : nil
|
11
|
+
token = AccessToken.valid.find_by_token access_token
|
12
|
+
resource = token ? token.user : nil
|
14
13
|
if validate(resource)
|
15
14
|
success! resource
|
16
15
|
elsif !halted?
|
@@ -19,6 +18,11 @@ module Devise
|
|
19
18
|
end
|
20
19
|
|
21
20
|
private
|
21
|
+
def access_token
|
22
|
+
tokens = [@req.access_token_in_header, @req.access_token_in_payload].compact
|
23
|
+
raise 'invalid request: access token exists in header and payload' if tokens.size > 1
|
24
|
+
tokens.first
|
25
|
+
end
|
22
26
|
# Simply invokes valid_for_authentication? with the given block and deal with the result.
|
23
27
|
def validate(resource, &block)
|
24
28
|
result = resource && resource.valid_for_authentication?(&block)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_oauth2_providable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Sonnek
|