devise_g5_authenticatable 0.1.1 → 0.1.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: c21c4321163499661d4fd43789dfcff59c38d10a
4
- data.tar.gz: 7ae73de16b05661c29a0a092da8191b2242f442b
3
+ metadata.gz: efb202ccac3050c390f4aee7ef1afdf625437574
4
+ data.tar.gz: 89c6a1f7f1aaebe7123a321c1ceec726ee17e4b7
5
5
  SHA512:
6
- metadata.gz: d75544ee10f7e7749c4f7b7a95504b76ff015d9bfc74dd168f7c369135c61d386622738f102843c20ff9c61f6872379688b20a09b187cbcb20f181645dbf2947
7
- data.tar.gz: e73c4a027bdbfa89f39078becfe6f15dd1c6931da06222e3f6456114c7eec55391ba23c87fe44215d2593e7b76a2f6eba85777c9c96ae0c2e69edc15367bd161
6
+ metadata.gz: 4af967f531a3b3e974cdb46d462cf86a25302357af9a46ff62bc864f4253a0c99759e0bd14c7a4394798bb331dfe559b7d072c6fe54aeecd60ee71564e28bf19
7
+ data.tar.gz: 075ebbe92655bb91e49b35df46341d546a6dc6994f6e482e22ebd74844b07ee234f1c138660edecc8bcd49b1a9c84eaa011a9a8a6a6ea4594f013001dac4c865
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v0.1.2 (2014-08-04)
2
+ * Use existing user with updated password on duplicate user creation with
3
+ duplicate email.
4
+
1
5
  ## v0.1.1 (2014-07-31)
2
6
  * Find a user by email when a duplicate email exception is returned from
3
7
  user creation.
@@ -23,13 +23,21 @@ module Devise
23
23
  auth_client.create_user(auth_user_args)
24
24
  rescue StandardError => e
25
25
  if e.message =~ /Email has already been taken/
26
- auth_client.find_user_by_email(model.email)
26
+ existing_auth_user
27
27
  else
28
28
  raise e
29
29
  end
30
30
  end
31
31
  end
32
32
 
33
+ def existing_auth_user
34
+ user = auth_client.find_user_by_email(model.email)
35
+ user.password = model.password
36
+ user.password_confirmation = model.password
37
+ auth_client.update_user(user.to_hash)
38
+ user
39
+ end
40
+
33
41
  def auth_user_exists?
34
42
  !model.uid.blank?
35
43
  end
@@ -1,3 +1,3 @@
1
1
  module DeviseG5Authenticatable
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -15,9 +15,17 @@ describe Devise::G5::AuthUserCreator do
15
15
  let(:updated_by) {}
16
16
  let(:password) { 'new password' }
17
17
  let(:password_confirmation) { 'new password confirmation' }
18
+ let(:other_password) { 'blah' }
18
19
 
19
20
  let(:auth_client) { double(:g5_authentication_client) }
20
- let(:auth_user) { double(:auth_user, id: uid, email: model.email, clean_up_passwords: nil) }
21
+
22
+ let(:auth_user) { double(:auth_user,
23
+ id: uid,
24
+ email: model.email,
25
+ password: other_password,
26
+ clean_up_passwords: nil,
27
+ to_hash: {}) }
28
+
21
29
  let(:uid) { 'remote-auth-user-42' }
22
30
 
23
31
  before do
@@ -29,11 +37,19 @@ describe Devise::G5::AuthUserCreator do
29
37
  model.uid = nil
30
38
  allow(auth_client).to receive(:create_user).and_raise(StandardError.new('Email has already been taken'))
31
39
  allow(auth_client).to receive(:find_user_by_email).and_return(auth_user)
32
- create
40
+ allow(auth_client).to receive(:update_user)
33
41
  end
34
42
 
35
43
  it 'should create the local user with the existing uid' do
36
- expect(model.uid).to eq(uid)
44
+ allow(auth_user).to receive(:password=)
45
+ allow(auth_user).to receive(:password_confirmation=)
46
+ expect{ create }.to change(model, :uid).to uid
47
+ end
48
+
49
+ it 'should reset the password' do
50
+ expect(auth_user).to receive(:password=).with(password)
51
+ expect(auth_user).to receive(:password_confirmation=).with(password)
52
+ create
37
53
  end
38
54
  end
39
55
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_g5_authenticatable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maeve Revels
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-31 00:00:00.000000000 Z
11
+ date: 2014-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: devise