metova 0.0.8 → 0.0.9

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YmVhYzhmMjZhNjQyNDFiMmRjZDFmODQ5ZjgyMjQ4MjRlNzBhZGQyYg==
4
+ YTRmMjlkYjFiZGIxNzU2M2FkNmY2NjM1MDM1MDQ0NDVkOTJhYzA1MA==
5
5
  data.tar.gz: !binary |-
6
- NTIwZjZmNDUwODMyYjRlMjViOGUzNzYyYjdjMTEzYmNhM2QzYWRjNw==
6
+ OGFiMWRhYjhiMzU2NWJlYjMyZGMyNGE5Yjc1ZTFhOWMxNDhjNjE0Mw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjFhMzk5NTI2MDA2MTFjYzBmZDM2OTA1YmRhZmQ5YjlkMmNiODk1ODM2ODM5
10
- NDNlZGI0OGYxZTBlNGNjZWZjMTliMjYzNzIyY2RjY2M5YmU0YWJkM2MxYTUz
11
- ZmM5Y2VmN2I0MjMxOTE4YmUxYTYxYjVlMjQwZDkyOTExMTYwZTU=
9
+ MzU1MjY2NjA2YzBlNGRmOWM3ZGUxZjM1NGFmMWU5MmRkOTg5MzI4YWEyOTA4
10
+ NTA4OGIyZmQxNzk2YTgzYjJkZmE3OTViNWI5ZGRjZTk3NWNiOTYwMGU2MDhi
11
+ N2YyYTJjYWM3MWY0YzYzNjI5OTMzNDIwODExMzU4Nzk4MmMxYTc=
12
12
  data.tar.gz: !binary |-
13
- ZTRjODc0YjEwMDMwMGMyMjU0YTBhMjQ1ZWZkYWU1MGYzYWUwZTMzNTliZTc1
14
- ODI0ZmIzNmEyYmQ2Y2Y0MTg5MGZiMmJkYmMzNzdkMWFkYjQ5OTU1NjVmNTYy
15
- ZGNmNzU2MDNlOWQyYjI2NjQ4NTdlMDA1NjM0ZWJmNGJjNWVjNTc=
13
+ NzI0M2Q4NjEyNjgzMmYwM2M4YWI5YTc1MGFjZjhjOWU2NDA5YmE0NjZlOTAw
14
+ NTVjZjhkNDllYzkzZjdhNmQxNzBmMWViZTdkYWUzYjg2M2M4NjMzMGJhNGU5
15
+ MjJmOTI1NWIwOWM0MzQ0NjI0MWVlZWJlMmM1MzE1OWY4NTBkMjY=
@@ -45,7 +45,9 @@ class Metova::OmniauthCallbacksController < ::Devise::OmniauthCallbacksControlle
45
45
  end
46
46
 
47
47
  def sign_up_user(auth, identity)
48
- user = User.new email: auth.info.email, password: SecureRandom.hex
48
+ Rails.logger.info "Omniauth callback data: #{auth.to_h}"
49
+ user = User.find_or_initialize_by(email: auth.info.email) { |new_user| new_user.password = SecureRandom.hex }
50
+
49
51
  if user.save and identity.update(user: user)
50
52
  sign_in_and_redirect :user, identity.user
51
53
  else
@@ -58,11 +60,15 @@ class Metova::OmniauthCallbacksController < ::Devise::OmniauthCallbacksControlle
58
60
  redirect_to after_invalid_user_sign_up_path
59
61
  end
60
62
 
61
- def redirect_with_notification(notification, path: main_app.root_path)
63
+ def redirect_with_notification(notification, path: after_successful_omniauth_path)
62
64
  redirect_to path, notice: notification
63
65
  end
64
66
 
65
67
  def after_invalid_user_sign_up_path
66
68
  main_app.new_user_registration_path
67
69
  end
70
+
71
+ def after_successful_omniauth_path
72
+ main_app.root_path
73
+ end
68
74
  end
@@ -3,6 +3,7 @@ module Metova
3
3
  belongs_to :user, required: true
4
4
 
5
5
  validates :uid, :provider, presence: true
6
+ validates :uid, uniqueness: { scope: :provider }
6
7
 
7
8
  def self.find_or_initialize_with_omniauth(auth)
8
9
  find_or_initialize_by uid: auth.uid, provider: auth.provider
@@ -6,14 +6,5 @@ module Metova
6
6
  require 'devise'
7
7
  require 'responders'
8
8
 
9
- # run engine migrations when running bin/rake db:migrate from the main app
10
- initializer :append_migrations do |app|
11
- unless app.root.to_s.match root.to_s
12
- config.paths['db/migrate'].expanded.each do |expanded_path|
13
- app.config.paths['db/migrate'] << expanded_path
14
- end
15
- end
16
- end
17
-
18
9
  end
19
10
  end
@@ -1,4 +1,6 @@
1
1
  require 'metova'
2
+ require 'open-uri'
3
+
2
4
  require 'metova/oauth/generic_provider'
3
5
  require 'metova/oauth/facebook_provider'
4
6
  require 'metova/oauth/twitter_provider'
@@ -1,10 +1,27 @@
1
1
  module Metova
2
2
  module Oauth
3
3
  class GoogleProvider < GenericProvider
4
+ GOOGLE_API_URL = 'https://www.googleapis.com/plus/v1/people/me'
5
+ ME_URL = -> (token) { "#{GOOGLE_API_URL}/me?access_token=#{token}" }
4
6
 
5
7
  def authenticate
8
+ self.info = OmniAuth::AuthHash.new me
9
+ self.uid = info.id
10
+ self
6
11
  end
7
12
 
13
+ def provider
14
+ :google_oauth2
15
+ end
16
+
17
+ private
18
+ def me
19
+ super do
20
+ client = OAuth2
21
+ token = OAuth2::AccessToken.new
22
+ JSON.parse URI.parse(ME_URL[access_token]).read
23
+ end
24
+ end
8
25
  end
9
26
  end
10
27
  end
@@ -1,3 +1,3 @@
1
1
  module Metova
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
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.8
4
+ version: 0.0.9
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-07-28 00:00:00.000000000 Z
11
+ date: 2015-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails