devise_oauth2_rails4 2.0.1 → 2.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22427ed5ab66d9da651871d64af020f2a2affca6
4
- data.tar.gz: 8fe7f6f4779876ea2ea872040d53d27ade881cd2
3
+ metadata.gz: ad0e15ec79488248298982fcf833bd85b03358d5
4
+ data.tar.gz: b26a39c3065e052a1fe782d33237347d1ca6e320
5
5
  SHA512:
6
- metadata.gz: 183c1aafe6a395f8b32468aeb846da3d5dccee9697afbcb8fa35513cbc6a16a036272815ac37b9199263eb5eeec7431e21ffc79891c7ad594bb44ebb47a8093d
7
- data.tar.gz: 98847d55f11d8af140b03132ed5e780cffc370208f8c8a11479852c8bf1d0b4e5d1c4844e33d7bee83f3e659b11da8ed6794cca2b0d288da91747ba3555d0b51
6
+ metadata.gz: 62ccff4b3461bf7592b9915a7a81e9d12b14f8520514b2053bfbf943afaface7225d4f86e1d526133d396ae5e26e693a52e3e9a669aeaea65490b380e038accb
7
+ data.tar.gz: 84dd9b90a0d08724d437e136f5eda3cc4ec4a07c34610ba4cc63968bba91c3426fa7dda2bebabbbedb110c215970ee5c02da99663f75528765829976c754e395
@@ -0,0 +1,58 @@
1
+ module Devise
2
+ module Oauth2
3
+ module Authorization
4
+ extend ActiveSupport::Concern
5
+
6
+ def current_oauth2_client(opts: { secure: false })
7
+ return @secure_client ||= Client.find_by(secret: client_secret) if opts[:secure]
8
+ return @secure_client ||= Client.find_by(id: current_access_token.client_id) if access_token?
9
+ @client ||= Client.find_by('identifier = :client_id OR secret = :secret', client_id: client_id, secret: client_secret) if client_credentials?
10
+ end
11
+
12
+ def current_access_token
13
+ @access_token ||= AccessToken.find_by(token: access_token)
14
+ end
15
+
16
+ def oauth2_client_signed_in?
17
+ !!@client
18
+ end
19
+
20
+ def access_token_signed_in?
21
+ !!@access_token
22
+ end
23
+
24
+ def client_credentials
25
+ client_id? || client_secret?
26
+ end
27
+
28
+ def client_credentials?
29
+ !!client_credentials
30
+ end
31
+
32
+ def client_secret
33
+ params[:client_secret]
34
+ end
35
+
36
+ def client_secret?
37
+ !!client_secret
38
+ end
39
+
40
+ def client_id
41
+ params[:client_id]
42
+ end
43
+
44
+ def client_id?
45
+ !!params[:client_id]
46
+ end
47
+
48
+ def access_token
49
+ params[:access_token]
50
+ end
51
+
52
+ def access_token?
53
+ !!access_token
54
+ end
55
+
56
+ end
57
+ end
58
+ end
@@ -1,5 +1,5 @@
1
1
  module Devise
2
2
  module Oauth2
3
- VERSION = "2.0.1"
3
+ VERSION = "2.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_oauth2_rails4
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Wheeler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-11 00:00:00.000000000 Z
11
+ date: 2014-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -166,6 +166,7 @@ files:
166
166
  - LICENSE.txt
167
167
  - README.md
168
168
  - Rakefile
169
+ - app/controllers/devise/oauth2/authorization.rb
169
170
  - app/controllers/devise/oauth2/authorizations_controller.rb
170
171
  - app/controllers/devise/oauth2/tokens_controller.rb
171
172
  - app/helpers/permissions_helper.rb