omniauth-multiprovider 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f91a138b2a60e02e2c38acc950045cae88281922
4
- data.tar.gz: b4743f78480676b0de284cd11e212009ead3258e
3
+ metadata.gz: 34da0ba445043816e1e3dd4f72f3c3551007c645
4
+ data.tar.gz: c533befeb3ee48612087b4420ece8865f4941c8c
5
5
  SHA512:
6
- metadata.gz: 3035045753961d2bb672c5ab90b0593a1845ea92f4572b610df5b4858fde5bb5825ae644ea083b2a2737b12999a2e3a7442275c21a5db5fe104a0895c08fece3
7
- data.tar.gz: f752d7732163ab562d2020120c2c190dfb7cdfb2f6b77361b85537431fbc6924ef2a7256254c99b75586322c2a583d3a0de82f3649ee4e76e711428c8e209137
6
+ metadata.gz: 0607783b50c1c221f17eda643f2ef9b49f2b26b320b27c3fea0686f680c69bc7ceddeb6a162a90c6698776e364774980270e66ddf480794989b666e6c58279df
7
+ data.tar.gz: 39a34d6b61b6aec6a071e11b7e715747662d75928475b9e2ff8aced3100338da182b8b60ba638763c6fb590681e1f56102058722ff812a24e6a7230d4bfcb29b
@@ -9,6 +9,7 @@ class Authentication < ActiveRecord::Base
9
9
  authentication = self.find_or_create(auth)
10
10
  authentication.access_token = auth.credentials.token
11
11
  authentication.resource = resource
12
+ resource.save(validate: false)
12
13
  authentication.save
13
14
  authentication
14
15
  end
@@ -8,7 +8,7 @@ module OmniAuth
8
8
  end
9
9
 
10
10
  def mocked_email?
11
- email.match /.*@from\-.*\.com$/
11
+ email.match(/.*@from\-.*\.com$/) != nil
12
12
  end
13
13
 
14
14
  def current_email
@@ -23,4 +23,4 @@ module OmniAuth
23
23
  end
24
24
 
25
25
  end
26
- end
26
+ end
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module MultiProvider
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  end
5
- end
5
+ end
@@ -12,6 +12,8 @@ module OmniAuth
12
12
  access_token = auth.credentials.token
13
13
  authentication = MultiProvider.authentication_klass.find_by(provider: provider_name, uid: auth.uid)
14
14
 
15
+ resource = nil
16
+
15
17
  if authentication
16
18
  if signed_in_resource
17
19
  if authentication.resource == signed_in_resource
@@ -20,8 +22,9 @@ module OmniAuth
20
22
  raise MultiProvider::Error.new 'already connected with other user'
21
23
  end
22
24
  end
23
- authentication.resource
24
- else
25
+ resource = authentication.resource
26
+ end
27
+ unless resource
25
28
  if auth.info[:email].blank?
26
29
  auth.info[:email] = MultiProvider::resource_klass.mock_email(provider_name, auth.uid)
27
30
  end
@@ -29,15 +32,15 @@ module OmniAuth
29
32
 
30
33
  raise MultiProvider::Error.new 'email_already_registered' if MultiProvider::resource_klass.find_by(email: email)
31
34
 
32
- resource = signed_in_resource || MultiProvider::resource_klass.create(
35
+ resource = signed_in_resource || MultiProvider::resource_klass.new(
33
36
  email: email,
34
37
  password: Devise.friendly_token[0,20]
35
38
  )
36
39
 
37
40
  MultiProvider.authentication_klass.from(auth, resource)
38
41
 
39
- resource
40
42
  end
43
+ resource
41
44
  end
42
45
 
43
46
  def self.authenticate_from_oauth(provider_name, omniauth_data)
@@ -5,12 +5,13 @@ module OmniAuth
5
5
  def self.init(provider_name)
6
6
  klass = self
7
7
  OmniAuth::MultiProvider::CallbacksController.add_callback(provider_name) do
8
- resource = klass.find_from_oauth(provider_name, request.env['omniauth.auth'], send(OmniAuth::MultiProvider::current_resource))
8
+ auth = request.env['omniauth.auth']
9
+ resource = klass.find_from_oauth(provider_name, auth, send(OmniAuth::MultiProvider::current_resource))
9
10
  if resource.persisted?
10
11
  sign_in_and_redirect resource, event: :authentication #this will throw if resource is not activated
11
12
  set_flash_message(:notice, :success, kind: provider_name.to_s.camelize) if is_navigational_format?
12
13
  else
13
- session["devise.#{provider_name}_data"] = auth
14
+ session["devise.#{provider_name}_data"] = auth.except('extra')
14
15
  redirect_to send("new_#{OmniAuth::MultiProvider::resource_mapping}_registration_url")
15
16
  end
16
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-multiprovider
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - German Del Zotto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-08 00:00:00.000000000 Z
11
+ date: 2014-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: devise