dc_tunnel 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dc_tunnel.rb +19 -12
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73c6efee8fa1e3825471d39b0a0f24c29055ae7f2605a98e6eb63921e94ca8bd
|
4
|
+
data.tar.gz: 27b329ac15d2f7f1b2800f67e699e6a8b99774d0a591e528751c4da0575fb739
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42fa2f5c3197c38800aa1b97e3d17e0eade4ba3cbd104dd0a78a61f3f32be23136586190fd7c6e4f831ce7585b2e0c7c364866142a3916cc35c6b4d8900bb70f
|
7
|
+
data.tar.gz: 089aa1c928184eca34759faf1512130fc92dc6bdf2cdc6d6003d62ec5ce93323e8dda901f3f1f6569c1cf857c5be33540404fcfabc2b0bb9ed5ee63b19bfe7ce
|
data/lib/dc_tunnel.rb
CHANGED
@@ -12,8 +12,9 @@ class DcTunnel
|
|
12
12
|
def http_get(url)
|
13
13
|
puts "Tunnel : start get #{url} "
|
14
14
|
res = Net::HTTP.get(URI(url))
|
15
|
+
puts "Tunnel : got response #{res} "
|
15
16
|
res = JSON.parse(res).symbolize_keys!
|
16
|
-
puts "Tunnel : got response #{res} "
|
17
|
+
puts "Tunnel : got symbolize_keys! response #{res} "
|
17
18
|
res
|
18
19
|
end
|
19
20
|
|
@@ -37,27 +38,30 @@ class DcTunnel
|
|
37
38
|
end
|
38
39
|
|
39
40
|
def get_user(id)
|
40
|
-
http_get self.sso_path("/users/#{id}")
|
41
|
+
self.http_get self.sso_path("/users/#{id}")
|
41
42
|
end
|
42
43
|
|
43
44
|
def get_factories(params = {})
|
44
|
-
http_get self.sso_path("/factories", params)
|
45
|
+
self.http_get self.sso_path("/factories", params)
|
45
46
|
end
|
46
47
|
|
47
48
|
def get_departments(params = {})
|
48
|
-
http_get self.sso_path('/departments', params)
|
49
|
+
self.http_get self.sso_path('/departments', params)
|
49
50
|
end
|
50
51
|
|
51
52
|
def get_users(params = {})
|
52
53
|
# available params:
|
53
54
|
# id phone department_ids factory_ids
|
54
|
-
http_get self.sso_path("/users", params)
|
55
|
+
self.http_get self.sso_path("/users", params)
|
55
56
|
end
|
56
57
|
|
57
58
|
def synchronize
|
58
|
-
res = http_get self.sso_path('/users', {:system_ids => [self.get_settings[:system_id]]})
|
59
|
-
res[
|
60
|
-
|
59
|
+
res = self.http_get self.sso_path('/users', {:system_ids => [self.get_settings[:system_id]]})
|
60
|
+
res[:users].each do |sso_user|
|
61
|
+
puts "sso_user is #{sso_user}"
|
62
|
+
puts "sso_user_id is #{sso_user[:id]}"
|
63
|
+
user = User.find_by_sso_id sso_user[:id]
|
64
|
+
puts "user is #{user}"
|
61
65
|
if user.nil?
|
62
66
|
create_attributes = {}
|
63
67
|
get_settings[:default_user_props].each do |item|
|
@@ -65,12 +69,15 @@ class DcTunnel
|
|
65
69
|
value = item[1]
|
66
70
|
create_attributes[name] = sso_user[name].present? ? sso_user[name] : value
|
67
71
|
end
|
72
|
+
puts "create_attributes is #{create_attributes}"
|
68
73
|
User.create create_attributes
|
69
74
|
else
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
75
|
+
update_attributes = {
|
76
|
+
name: sso_user[:name],
|
77
|
+
phone: sso_user[:phone]
|
78
|
+
}
|
79
|
+
puts "update_attributes is #{update_attributes}"
|
80
|
+
user.update(update_attributes)
|
74
81
|
end
|
75
82
|
end
|
76
83
|
end
|