metova 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/controllers/metova/api/sessions_controller.rb +1 -1
- data/lib/metova/oauth.rb +2 -0
- data/lib/metova/oauth/error/devise_not_configured.rb +8 -0
- data/lib/metova/oauth/facebook_provider.rb +4 -5
- data/lib/metova/oauth/flux_provider.rb +4 -5
- data/lib/metova/oauth/generic_provider.rb +26 -5
- data/lib/metova/oauth/google_provider.rb +6 -7
- data/lib/metova/oauth/twitter_provider.rb +12 -12
- data/lib/metova/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NWYxMjlmMjEyNzY2ZDI5ODk2ZTQyMjc1MGNmM2JmNTE0MGNjOGQwNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MWQ2NjA5YjU1NmI2NDYxMTYwZjU2OTNjNGNiZDRhNDlhNDU1NWE0Yg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjJlYjE2ZGJiNjFjMWJkMGE0Y2ZlNDlmZDNkYjY2YzY4OTY3MzE4MjYyNzA0
|
10
|
+
MGQxZTZjYzMwM2Q0YzM2YzVlNzA5NDg4MTg4NTBhZmVjYWM0OTcyYTUzMTA4
|
11
|
+
ZWIzZmQzZTgzNzcxODg1ZjQxODFkMGI3MjJmYzg2NmQzOTAwM2E=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NmYyOTU3YzVlOTYzMjc1NzBjNGI0NDlmYzNkNjdjNTY1ZjBkYzBjYzgyMjZm
|
14
|
+
YzVkNDgzNDA2ZDY2ODcyZmJjZTNlZDkwNjk4NWYxN2ExYjU5NDA1MWNhYzRi
|
15
|
+
ODAxMmRjNDlmNzg3MTBmZmJiMTJiYjk0ODcyMWUyNWJjODE4NzA=
|
@@ -51,7 +51,7 @@ class Metova::API::SessionsController < ::Devise::SessionsController
|
|
51
51
|
respond_with user
|
52
52
|
end
|
53
53
|
else
|
54
|
-
render json: Metova::GenericError.new("#{auth.name} authentication failed")
|
54
|
+
render json: Metova::GenericError.new("#{auth.name} authentication failed"), status: 401
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
data/lib/metova/oauth.rb
CHANGED
@@ -16,6 +16,32 @@ module Metova
|
|
16
16
|
'OAuth'
|
17
17
|
end
|
18
18
|
|
19
|
+
protected
|
20
|
+
def me(&block)
|
21
|
+
yield
|
22
|
+
# rescue errors
|
23
|
+
end
|
24
|
+
|
25
|
+
def setup_with_devise?
|
26
|
+
devise_configuration.present?
|
27
|
+
end
|
28
|
+
|
29
|
+
def devise_configuration
|
30
|
+
::Devise.omniauth_configs[provider]
|
31
|
+
end
|
32
|
+
|
33
|
+
def devise_strategy
|
34
|
+
devise_configuration.strategy
|
35
|
+
end
|
36
|
+
|
37
|
+
def consumer_key
|
38
|
+
devise_strategy.consumer_key
|
39
|
+
end
|
40
|
+
|
41
|
+
def consumer_secret
|
42
|
+
devise_strategy.consumer_secret
|
43
|
+
end
|
44
|
+
|
19
45
|
private
|
20
46
|
def self.find_provider(provider)
|
21
47
|
map = {
|
@@ -27,11 +53,6 @@ module Metova
|
|
27
53
|
|
28
54
|
map.fetch provider.to_sym
|
29
55
|
end
|
30
|
-
|
31
|
-
def me(&block)
|
32
|
-
yield
|
33
|
-
# rescue errors
|
34
|
-
end
|
35
56
|
end
|
36
57
|
end
|
37
58
|
end
|
@@ -18,14 +18,13 @@ module Metova
|
|
18
18
|
:google_oauth2
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
JSON.parse URI.parse(ME_URL[access_token]).read
|
27
|
-
end
|
21
|
+
def me
|
22
|
+
super do
|
23
|
+
client = OAuth2
|
24
|
+
token = OAuth2::AccessToken.new
|
25
|
+
JSON.parse URI.parse(ME_URL[access_token]).read
|
28
26
|
end
|
27
|
+
end
|
29
28
|
end
|
30
29
|
end
|
31
30
|
end
|
@@ -19,22 +19,22 @@ module Metova
|
|
19
19
|
:twitter
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
JSON.parse(oauth_access_token.get(ME_URL).body)
|
26
|
-
end
|
22
|
+
def me
|
23
|
+
super do
|
24
|
+
JSON.parse oauth_access_token.get(ME_URL).body
|
27
25
|
end
|
26
|
+
end
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
def oauth_access_token
|
29
|
+
OAuth::AccessToken.from_hash consumer, oauth_token: access_token, oauth_token_secret: token_secret
|
30
|
+
end
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
def consumer
|
33
|
+
@consumer ||= begin
|
34
|
+
raise Metova::Oauth::Error::DeviseNotConfigured.new unless setup_with_devise?
|
35
|
+
OAuth::Consumer.new(consumer_key, consumer_secret, site: TWITTER_SITE_URL, scheme: :header)
|
37
36
|
end
|
37
|
+
end
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
data/lib/metova/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metova
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Logan Serman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -252,6 +252,7 @@ files:
|
|
252
252
|
- lib/metova/mandrill/railtie.rb
|
253
253
|
- lib/metova/models/filterable.rb
|
254
254
|
- lib/metova/oauth.rb
|
255
|
+
- lib/metova/oauth/error/devise_not_configured.rb
|
255
256
|
- lib/metova/oauth/facebook_provider.rb
|
256
257
|
- lib/metova/oauth/flux_provider.rb
|
257
258
|
- lib/metova/oauth/generic_provider.rb
|