auth-lh 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/auth/lh/api.rb +16 -2
- data/lib/auth/lh/user.rb +2 -2
- data/lib/auth/lh/version.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: dc1e3adcd34051edf7cc9bc3875417a37a851589
|
4
|
+
data.tar.gz: 22a41cf358bfe8ded9d7c4c86c238d8adc7cb39b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ef5f6f956b44c1775e35c50e71ea7aa150e8cf107bd534c34ca0baf6774baf2761b52bc48441c5a5e11ddadd513d7a86a99d054c9b6cb024221cc62432b0423
|
7
|
+
data.tar.gz: e6b4c723e0b384661a13648c36dcac79f5df3d299c78c831f28ea0f0fe2300ecca8377fb102fe360da493dd8994b243612813ee6b54db60b9af623918bee4ab5
|
data/CHANGELOG.md
CHANGED
data/lib/auth/lh/api.rb
CHANGED
@@ -30,6 +30,15 @@ module Auth
|
|
30
30
|
"#{@endpoint}/logout?return=#{CGI::escape(@return_url)}"
|
31
31
|
end
|
32
32
|
|
33
|
+
def get_user(code_or_login)
|
34
|
+
User.new(get_request("/api/user/#{code_or_login}"))
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_users(filters={})
|
38
|
+
results = get_request("/api/users", filters)
|
39
|
+
results.map { |r| User.new(r) }
|
40
|
+
end
|
41
|
+
|
33
42
|
protected
|
34
43
|
|
35
44
|
def create_login_attempt
|
@@ -42,11 +51,16 @@ module Auth
|
|
42
51
|
end
|
43
52
|
|
44
53
|
def get_request(action, params={})
|
45
|
-
|
54
|
+
response = RestClient.get("#{@endpoint}#{action}", {params: params}.merge(auth_headers))
|
55
|
+
JSON.parse(response.body)
|
46
56
|
end
|
47
57
|
|
48
58
|
def post_request(action, params={})
|
49
|
-
JSON.parse(RestClient.post("#{@endpoint}#{action}", params))
|
59
|
+
JSON.parse(RestClient.post("#{@endpoint}#{action}", params, auth_headers))
|
60
|
+
end
|
61
|
+
|
62
|
+
def auth_headers
|
63
|
+
{ authorization: "Token token=\"#{@access_token}\"" }
|
50
64
|
end
|
51
65
|
end
|
52
66
|
end
|
data/lib/auth/lh/user.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Auth
|
2
2
|
module Lh
|
3
3
|
class User
|
4
|
-
attr_accessor :code, :email, :jabber, :name, :login,
|
5
|
-
:
|
4
|
+
attr_accessor :code, :email, :jabber, :name, :login, :shop_code,
|
5
|
+
:is_admin, :allow_remote_access, :last_activity
|
6
6
|
|
7
7
|
def initialize(attributes={})
|
8
8
|
attributes.each do |k,v|
|
data/lib/auth/lh/version.rb
CHANGED