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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDFiZDg5N2UxN2E5ZDIxY2NiMmI4YjhkYzRmY2Y3OGIzYWFjYjA0ZA==
4
+ NWYxMjlmMjEyNzY2ZDI5ODk2ZTQyMjc1MGNmM2JmNTE0MGNjOGQwNg==
5
5
  data.tar.gz: !binary |-
6
- MWEzZTNkYmY5OWNiNGYwNzVlOGQwMWRiODg4Y2EwMWUzODY5ZGVlZg==
6
+ MWQ2NjA5YjU1NmI2NDYxMTYwZjU2OTNjNGNiZDRhNDlhNDU1NWE0Yg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDhlYzQ1YzdlZDk5MDcxZTk2NzAzMGNiZTBiYTMxMzM1MGRjNTI3NzgxMDU0
10
- Yzc2OWFkNGM0ZWI0Y2E1NTEwMDZmMWRlYTA2MzQ5YTY1MjkxNzdlNGU5ZDZh
11
- NjNkYjNlM2QzZmFmMjM4Mjc5MGRjMTliOGVlMmQ2MDFlYWZiZTE=
9
+ NjJlYjE2ZGJiNjFjMWJkMGE0Y2ZlNDlmZDNkYjY2YzY4OTY3MzE4MjYyNzA0
10
+ MGQxZTZjYzMwM2Q0YzM2YzVlNzA5NDg4MTg4NTBhZmVjYWM0OTcyYTUzMTA4
11
+ ZWIzZmQzZTgzNzcxODg1ZjQxODFkMGI3MjJmYzg2NmQzOTAwM2E=
12
12
  data.tar.gz: !binary |-
13
- NmIzNjU1NDc4YmI0NjJkOTc5NDQxYmVlYmZmNGQ2NTRjOTA5NzYwMDQxN2Zk
14
- ZGZhYTk5YmY4MGExY2FkMDNlOGE1YzY4ZjFiMDE2YWVlMzkzZTM5NmQ5OTg2
15
- ZDY5YzI1MGRlZTllNTBhOTljM2U5M2UxMmIzOWZhYzhhOGU0NDM=
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
@@ -7,6 +7,8 @@ require 'metova/oauth/twitter_provider'
7
7
  require 'metova/oauth/flux_provider'
8
8
  require 'metova/oauth/google_provider'
9
9
 
10
+ require 'metova/oauth/error/devise_not_configured'
11
+
10
12
  begin
11
13
  require 'omniauth'
12
14
  rescue LoadError
@@ -0,0 +1,8 @@
1
+ module Metova
2
+ module Oauth
3
+ module Error
4
+ class DeviseNotConfigured < StandardError
5
+ end
6
+ end
7
+ end
8
+ end
@@ -18,12 +18,11 @@ module Metova
18
18
  :facebook
19
19
  end
20
20
 
21
- private
22
- def me
23
- super do
24
- JSON.parse URI.parse(ME_URL[access_token]).read
25
- end
21
+ def me
22
+ super do
23
+ JSON.parse URI.parse(ME_URL[access_token]).read
26
24
  end
25
+ end
27
26
  end
28
27
  end
29
28
  end
@@ -18,12 +18,11 @@ module Metova
18
18
  :flux
19
19
  end
20
20
 
21
- private
22
- def me
23
- super do
24
- JSON.parse URI.parse(ME_URL[access_token]).read
25
- end
21
+ def me
22
+ super do
23
+ JSON.parse URI.parse(ME_URL[access_token]).read
26
24
  end
25
+ end
27
26
  end
28
27
  end
29
28
  end
@@ -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
- private
22
- def me
23
- super do
24
- client = OAuth2
25
- token = OAuth2::AccessToken.new
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
- private
23
- def me
24
- super do
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
- def oauth_access_token
30
- OAuth::AccessToken.from_hash consumer, oauth_token: access_token, oauth_token_secret: token_secret
31
- end
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
- def consumer
34
- @consumer ||= begin
35
- OAuth::Consumer.new(ENV['TWITTER_APP_ID'], ENV['TWITTER_APP_SECRET'], site: TWITTER_SITE_URL, scheme: :header)
36
- end
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
@@ -1,3 +1,3 @@
1
1
  module Metova
2
- VERSION = '0.0.10'
2
+ VERSION = '0.0.11'
3
3
  end
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.10
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-09-30 00:00:00.000000000 Z
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