authful 0.5.19 → 0.5.20
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 +8 -8
- data/lib/authful/api.rb +25 -10
- data/lib/authful/response.rb +1 -1
- data/spec/lib/authful/api_spec.rb +18 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NmE5NTczMzk3NjBlMzE5Y2U3MWI5MmM2NjJiZDNlYmZlOWQyY2Y5ZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDI4MmMzYzdlYTA3ZmE3NjQzMDBiNzNjNzk3OWJkMzAwNDcwZWRlYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YWM2MmFhZDViYzMxMDQ5MTQ1YTkwZTAyMzY1MmYzM2IyMTczMjdlMzYzMjRh
|
10
|
+
ZDhlODdmZmQxMGFmMDJjN2I4MTdiODFlNjk2MDMzYzI3ZmQ2YmMzMDE2MDM4
|
11
|
+
ODEyYjRmOTZjN2Y4YjI2OGI0MzRmYjYzMzU2MzMwOGQ1N2FkMDM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZWFjNGU2YWM5M2U1YjVmYTkzYzlhZmYyMTJjMjMwNjgwODY4YjAxZWZjNTVh
|
14
|
+
YmFkM2QwZmIyZTJhYjk3NmRjNzQ2NTU0Mzg4MDk2ZjAzNTkyYzM0MjI5ZjI1
|
15
|
+
M2YyYzBjY2MxN2M4ZGM0NGU1N2E1ODY3OWI3Y2FmYjEwNzM1YWE=
|
data/lib/authful/api.rb
CHANGED
@@ -5,26 +5,34 @@ module Authful
|
|
5
5
|
end
|
6
6
|
|
7
7
|
module ClassMethods
|
8
|
-
def enroll(email)
|
9
|
-
res = Authful.send_request(:post, "/api/users", email: email)
|
10
|
-
return Authful::Response.new(
|
8
|
+
def enroll(email, phone = nil)
|
9
|
+
res = Authful.send_request(:post, "/api/users", email: email, phone: phone)
|
10
|
+
return Authful::Response.new(res)
|
11
11
|
end
|
12
12
|
|
13
13
|
def validate(token, otp)
|
14
|
-
Authful.send_request(:get, "/api/users/#{token}/validate", token: otp)
|
14
|
+
res = Authful.send_request(:get, "/api/users/#{token}/validate", token: otp)
|
15
|
+
res["ok"] == 1
|
15
16
|
end
|
16
17
|
|
17
18
|
def send_sms(token)
|
18
|
-
Authful.send_request(:get, "/api/users/#{token}/send_sms")
|
19
|
+
res = Authful.send_request(:get, "/api/users/#{token}/send_sms")
|
20
|
+
res["ok"] == 1
|
19
21
|
end
|
20
22
|
|
21
|
-
def
|
22
|
-
Authful.send_request(:
|
23
|
+
def send_fallback_sms(token)
|
24
|
+
res = Authful.send_request(:get, "/api/users/#{token}/fallback")
|
25
|
+
res["ok"] == 1
|
26
|
+
end
|
27
|
+
|
28
|
+
def set_fallback_phone(token, phone)
|
29
|
+
res = Authful.send_request(:patch, "/api/users/#{token}/fallback", phone: phone)
|
30
|
+
res["error"] == nil
|
23
31
|
end
|
24
32
|
|
25
33
|
def reset(token, send_sms = false)
|
26
34
|
res = Authful.send_request(:patch, "/api/users/#{token}/reset")
|
27
|
-
return Authful::Response.new(
|
35
|
+
return Authful::Response.new(res)
|
28
36
|
end
|
29
37
|
|
30
38
|
def generate_recovery_codes(token)
|
@@ -32,12 +40,19 @@ module Authful
|
|
32
40
|
res["recovery_codes"]
|
33
41
|
end
|
34
42
|
|
43
|
+
def view_recovery_codes(token)
|
44
|
+
res = Authful.send_request(:get, "/api/users/#{token}/recovery_codes")
|
45
|
+
res["recovery_codes"]
|
46
|
+
end
|
47
|
+
|
35
48
|
def validate_recovery_code(token, code)
|
36
|
-
Authful.send_request(:get, "/api/users/#{token}/recovery_codes"
|
49
|
+
res = Authful.send_request(:get, "/api/users/#{token}/recovery_codes/#{code}")
|
50
|
+
res["ok"] == 1
|
37
51
|
end
|
38
52
|
|
39
53
|
def unenroll(token)
|
40
|
-
Authful.send_request(:delete, "/api/users/#{token}")
|
54
|
+
res = Authful.send_request(:delete, "/api/users/#{token}")
|
55
|
+
res["ok"] == 1
|
41
56
|
end
|
42
57
|
end
|
43
58
|
end
|
data/lib/authful/response.rb
CHANGED
@@ -54,12 +54,18 @@ describe Authful do
|
|
54
54
|
Authful.validate("user-authful-token", "000000").should eq(false)
|
55
55
|
end
|
56
56
|
|
57
|
-
it "sends sms to
|
57
|
+
it "sends sms to user" do
|
58
58
|
FakeWeb.register_uri :get, "https://my-endpoint.dev/authful/api/users/user-authful-token/send_sms", {body: {ok: 1}.to_json}
|
59
59
|
|
60
60
|
Authful.send_sms("user-authful-token").should eq(true)
|
61
61
|
end
|
62
62
|
|
63
|
+
it "sends fallback sms to user" do
|
64
|
+
FakeWeb.register_uri :get, "https://my-endpoint.dev/authful/api/users/user-authful-token/fallback", {body: {ok: 1}.to_json}
|
65
|
+
|
66
|
+
Authful.send_fallback_sms("user-authful-token").should eq(true)
|
67
|
+
end
|
68
|
+
|
63
69
|
it "catches failed sms" do
|
64
70
|
FakeWeb.register_uri :get, "https://my-endpoint.dev/authful/api/users/user-authful-token/send_sms", {body: {error: "It just didn't send"}.to_json, status: [400, "Bad Request"]}
|
65
71
|
|
@@ -74,10 +80,10 @@ describe Authful do
|
|
74
80
|
res.qr_code.should eq('qr-code')
|
75
81
|
end
|
76
82
|
|
77
|
-
it "sets phone number for user" do
|
78
|
-
FakeWeb.register_uri :patch, "https://my-endpoint.dev/authful/api/users/user-authful-token/
|
83
|
+
it "sets fallback phone number for user" do
|
84
|
+
FakeWeb.register_uri :patch, "https://my-endpoint.dev/authful/api/users/user-authful-token/fallback", {body: {ok: 1}.to_json}
|
79
85
|
|
80
|
-
Authful.
|
86
|
+
Authful.set_fallback_phone("user-authful-token", "12005551212").should eq(true)
|
81
87
|
end
|
82
88
|
|
83
89
|
it "generates recovery codes" do
|
@@ -86,14 +92,20 @@ describe Authful do
|
|
86
92
|
Authful.generate_recovery_codes("user-authful-token").length.should eq(1)
|
87
93
|
end
|
88
94
|
|
95
|
+
it "view recovery codes" do
|
96
|
+
FakeWeb.register_uri :get, "https://my-endpoint.dev/authful/api/users/user-authful-token/recovery_codes", {body: {ok: 1, recovery_codes: ["00000 11111 22222"]}.to_json}
|
97
|
+
|
98
|
+
Authful.generate_recovery_codes("user-authful-token").length.should eq(1)
|
99
|
+
end
|
100
|
+
|
89
101
|
it "validates recovery code" do
|
90
|
-
FakeWeb.register_uri :get, "https://my-endpoint.dev/authful/api/users/user-authful-token/recovery_codes
|
102
|
+
FakeWeb.register_uri :get, "https://my-endpoint.dev/authful/api/users/user-authful-token/recovery_codes/000001111122222", {body: {ok: 1}.to_json}
|
91
103
|
|
92
104
|
Authful.validate_recovery_code("user-authful-token", "000001111122222").should eq(true)
|
93
105
|
end
|
94
106
|
|
95
107
|
it "does not validate invalid recovery code" do
|
96
|
-
FakeWeb.register_uri :get, "https://my-endpoint.dev/authful/api/users/user-authful-token/recovery_codes
|
108
|
+
FakeWeb.register_uri :get, "https://my-endpoint.dev/authful/api/users/user-authful-token/recovery_codes/000001111100000", {body: {error: "invalid recovery code"}.to_json, status: ["403", "invalid recovery code"]}
|
97
109
|
|
98
110
|
Authful.validate_recovery_code("user-authful-token", "000001111100000").should eq(false)
|
99
111
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Wyrosdick
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|