devise_capturable 0.0.11 → 0.0.12
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 +4 -4
- data/lib/devise_capturable/strategy.rb +10 -2
- data/lib/devise_capturable/version.rb +1 -1
- data/lib/devise_capturable.rb +1 -0
- data/spec/strategy_spec.rb +1 -1
- data/spec/view_helpers_spec.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa713fc1f447c824492470413d64c1c75f853c17
|
4
|
+
data.tar.gz: 9090c336193d4110528b5e9fcd4318023f8baa63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/devise_capturable.rb
CHANGED
@@ -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])
|
data/spec/strategy_spec.rb
CHANGED
@@ -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(:
|
48
|
+
expect(@strategy).to receive(:fail!).with("Login failed: Exception")
|
49
49
|
expect { @strategy.authenticate! }.to_not raise_error
|
50
50
|
end
|
51
51
|
|
data/spec/view_helpers_spec.rb
CHANGED
@@ -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
|
12
|
+
link.should == '<a class="capture_modal_open" href="#" id="capture_signin_link">Login</a>'
|
13
13
|
end
|
14
14
|
|
15
15
|
end
|