omniauth-draugiem 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -1
- data/Gemfile +1 -1
- data/lib/omniauth-draugiem/version.rb +1 -1
- data/lib/omniauth/strategies/draugiem.rb +6 -5
- data/omniauth-draugiem.gemspec +1 -1
- data/spec/omniauth/strategies/draugiem_spec.rb +30 -6
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3522a225714401cb6d46a60a90cb3d80d1144cc
|
4
|
+
data.tar.gz: d65d9883674c351bca10a0be45d1b04e66d528ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 910ee5d048cd445c3f70bee5ef6a16b77a62d155befe6687d0940df6753f2a78fe020fa3140a3ae26ca75b2dd4732bd0f7801875ccb823383a801eb265bb1ad9
|
7
|
+
data.tar.gz: de66d56525721d824558d2c8811901cd98fc3e62e48484087c234b4406f0443bbaf45d27326cd1cda319105f17a732aaa5c3741332202c2c1eb196d71970df6f
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -55,23 +55,24 @@ module OmniAuth
|
|
55
55
|
fail!(:invalid_response, e)
|
56
56
|
end
|
57
57
|
|
58
|
-
uid { @auth_data['uid'] }
|
58
|
+
uid { @auth_data['uid'].to_s }
|
59
59
|
|
60
60
|
credentials do
|
61
61
|
{ 'apikey' => @auth_data['apikey'] }
|
62
62
|
end
|
63
63
|
|
64
64
|
info do
|
65
|
-
if @auth_data['users'] && @auth_data['users'][@auth_data['uid']]
|
66
|
-
user = @auth_data['users'][@auth_data['uid']]
|
65
|
+
if @auth_data['users'] && @auth_data['users'][@auth_data['uid'].to_s]
|
66
|
+
user = @auth_data['users'][@auth_data['uid'].to_s]
|
67
67
|
{
|
68
68
|
'name' => "#{user['name']} #{user['surname']}",
|
69
69
|
'nickname' => user['nick'],
|
70
|
+
'email' => user['email'],
|
70
71
|
'first_name' => user['name'],
|
71
72
|
'last_name' => user['surname'],
|
72
73
|
'location' => user['place'],
|
73
|
-
'age' => user['age']
|
74
|
-
'adult' => user['adult'] ==
|
74
|
+
'age' => user['age'] ? user['age'] : nil,
|
75
|
+
'adult' => (user['adult'] == 1),
|
75
76
|
'image' => user['img'],
|
76
77
|
'sex' => user['sex']
|
77
78
|
}
|
data/omniauth-draugiem.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
21
|
s.add_runtime_dependency "omniauth", "~> 1.0"
|
22
|
-
s.add_runtime_dependency "rest-client", "~> 1
|
22
|
+
s.add_runtime_dependency "rest-client", "~> 2.0.1"
|
23
23
|
s.add_runtime_dependency "multi_json", "~> 1.0"
|
24
24
|
|
25
25
|
s.add_development_dependency "bundler", "~> 1.5"
|
@@ -24,28 +24,52 @@ describe 'OmniAuth::Strategies::Draugiem', :type => :strategy do
|
|
24
24
|
stub_request(:get, "https://api.draugiem.lv/json/?action=authorize&app=abc&code=123456").
|
25
25
|
to_return(:body => MultiJson.encode({
|
26
26
|
'apikey'=>"123456789",
|
27
|
-
'uid'=>
|
27
|
+
'uid'=>100,
|
28
28
|
'language'=>"lv",
|
29
29
|
'users'=>{
|
30
30
|
'100'=>{
|
31
|
-
'uid'=>
|
31
|
+
'uid'=>100,
|
32
32
|
'name'=>"John",
|
33
33
|
'surname'=>"Lenon",
|
34
34
|
'nick'=>"johnybravo",
|
35
35
|
'place'=>"Durbe",
|
36
|
-
'age'=>
|
37
|
-
'adult'=>
|
36
|
+
'age'=>false,
|
37
|
+
'adult'=> 1,
|
38
38
|
'img'=>"https://4.bp.blogspot.com/_ZmXOoYjxXog/Sg2jby1RFSI/AAAAAAAAE_Q/1LpfjimAz50/s400/JohnnyBravo3.gif",
|
39
39
|
'sex'=>"M"
|
40
40
|
}
|
41
41
|
}
|
42
42
|
}))
|
43
43
|
get '/auth/draugiem/callback?dr_auth_status=ok&dr_auth_code=123456'
|
44
|
-
|
45
44
|
expect(last_request.env['omniauth.auth']['credentials']['apikey']).to eq "123456789"
|
46
45
|
expect(last_request.env['omniauth.auth']['info']['location']).to eq "Durbe"
|
47
46
|
expect(last_request.env['omniauth.auth']['info']['age']).to be nil
|
48
47
|
expect(last_request.env['omniauth.auth']['info']['adult']).to be true
|
49
48
|
end
|
49
|
+
|
50
|
+
it 'should gather user data after success authorization when age is 8 and not adult' do
|
51
|
+
stub_request(:get, "https://api.draugiem.lv/json/?action=authorize&app=abc&code=123456").
|
52
|
+
to_return(:body => MultiJson.encode({
|
53
|
+
'apikey'=>"123456789",
|
54
|
+
'uid'=>100,
|
55
|
+
'language'=>"lv",
|
56
|
+
'users'=>{
|
57
|
+
'100'=>{
|
58
|
+
'uid'=>100,
|
59
|
+
'name'=>"John",
|
60
|
+
'surname'=>"Lenon",
|
61
|
+
'nick'=>"johnybravo",
|
62
|
+
'place'=>"Durbe",
|
63
|
+
'age'=>8,
|
64
|
+
'adult'=> 0,
|
65
|
+
'img'=>"https://4.bp.blogspot.com/_ZmXOoYjxXog/Sg2jby1RFSI/AAAAAAAAE_Q/1LpfjimAz50/s400/JohnnyBravo3.gif",
|
66
|
+
'sex'=>"M"
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}))
|
70
|
+
get '/auth/draugiem/callback?dr_auth_status=ok&dr_auth_code=123456'
|
71
|
+
expect(last_request.env['omniauth.auth']['info']['age']).to be 8
|
72
|
+
expect(last_request.env['omniauth.auth']['info']['adult']).to be false
|
73
|
+
end
|
50
74
|
end
|
51
|
-
end
|
75
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-draugiem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edgars Beigarts
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-02-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: omniauth
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: 2.0.1
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: 2.0.1
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: multi_json
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|