devise_capturable 0.0.11 → 0.0.12

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: 644bbd9ac34e9e0e96685a4626fd1d680955761f
4
- data.tar.gz: 37700b34d7429bd51ed96f1c3fd8f48b069c5a2a
3
+ metadata.gz: aa713fc1f447c824492470413d64c1c75f853c17
4
+ data.tar.gz: 9090c336193d4110528b5e9fcd4318023f8baa63
5
5
  SHA512:
6
- metadata.gz: f910d625c110ec01d7cfd635b7b629025f961ef6b8202654e9817f1f78c7ab336a658468de49198f59736adf634d4eb314fbe45136d44e2409de46c0e7d69b18
7
- data.tar.gz: 878d25efc4c8410bb944e91490542514aaa41d57bfa24354a47a2647001731f798e3f4e246625fa700c1d2517a58cb70fb4bab3d8f17bf3496e7c7825f20e83a
6
+ metadata.gz: 278fd200e8f9af1654a7b2e362d598f85376acb11077be4b3bf4e765e2dc4ae885edeeadc176fccc1944ac671cbfcce04ba5f843fb06c6d8a7da1c98f70f3205
7
+ data.tar.gz: baabd8d4040a9f97a0114a579cc79d914a378d5a4ddfc579124fd340d834c5eb867522b0b1af8865201bcbabf704489ffb0d8f1a0b679c68a6cb2035d7b7e4a1
@@ -17,23 +17,31 @@ module Devise
17
17
  klass = mapping.to
18
18
 
19
19
  begin
20
+
21
+ # get an access token from an OAUTH code
20
22
  token = Devise::Capturable::API.token(params[:code])
21
23
  fail!(:capturable_invalid) unless token['stat'] == 'ok'
22
-
24
+
25
+ # get the user info form the access token
23
26
  entity = Devise::Capturable::API.entity(token['access_token'])
27
+
28
+ # find user with the capturable params
24
29
  user = klass.find_with_capturable_params(entity["result"])
25
30
 
31
+ # if the user exists
26
32
  if user
27
33
  user.before_capturable_sign_in(entity["result"], params)
34
+ # if the user does not exist
28
35
  else
29
36
  user = klass.new
30
37
  user.before_capturable_create(entity["result"], params)
31
38
  user.save!
32
39
  end
33
40
 
41
+ # sign in the user
34
42
  success!(user)
43
+
35
44
  rescue Exception => e
36
- puts e.inspect
37
45
  fail!("Login failed: #{e.to_s}")
38
46
  end
39
47
  end
@@ -1,5 +1,5 @@
1
1
  module Devise
2
2
  module Capturable
3
- VERSION = "0.0.11"
3
+ VERSION = "0.0.12"
4
4
  end
5
5
  end
@@ -12,6 +12,7 @@ module Devise
12
12
  mattr_accessor :capturable_client_id
13
13
  mattr_accessor :capturable_client_secret
14
14
  mattr_accessor :capturable_redirect_uri
15
+ mattr_accessor :capturable_auto_create_account
15
16
  end
16
17
 
17
18
  I18n.load_path.unshift File.join(File.dirname(__FILE__), *%w[devise_capturable locales en.yml])
@@ -45,7 +45,7 @@ describe 'Devise::Capturable' do
45
45
  it "should fail if unsuccessful" do
46
46
  expect(@user).to receive(:save!).and_raise(Exception)
47
47
  expect(@strategy).to_not receive(:success!)
48
- expect(@strategy).to receive(:fail!).with(:capturable_invalid)
48
+ expect(@strategy).to receive(:fail!).with("Login failed: Exception")
49
49
  expect { @strategy.authenticate! }.to_not raise_error
50
50
  end
51
51
 
@@ -9,7 +9,7 @@ describe 'View Helpers' do
9
9
  end
10
10
  test = Testing.new
11
11
  link = test.link_to_capturable("Login")
12
- link.should == '<a href="#" class="capture_modal_open" id="capture_signin_link">Login</a>'
12
+ link.should == '<a class="capture_modal_open" href="#" id="capture_signin_link">Login</a>'
13
13
  end
14
14
 
15
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_capturable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rune Skjoldborg Madsen