7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/auth/centric/captcha/retrieve.rb', line 7
def retrieve_captcha
return true unless enabled?
payload = {
security_captcha: {
ip: @ip_address,
session_id: @session_id
}
}
http = HTTP
.timeout(timeout_seconds)
.(apikey:)
.post(find_or_create_path, json: payload)
case http.status
when 200..202
JSON.parse(http.body)['data']['attributes'].except('session_id', 'ip')
when 422
raise Error, http.body.to_s
else
raise Error, "#{http.status}: #{http.body}"
end
rescue HTTP::TimeoutError
true
end
|