andrewfun 0.0.5 → 0.0.9

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/andrewfun.rb +32 -2
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c357e827f5cbc2f57b236098e425620fe6ebaecef3f6c4f0ae8559fb56cafc31
4
- data.tar.gz: b2b548da670200ae797d0f90d63f50ebc11fa1ccb5e09e77aa8290c82707f9a1
3
+ metadata.gz: da26724b7ab0b87b05f879f15945533174fb608ead485347cc05a924e0da9717
4
+ data.tar.gz: 5dbbab34ec08e09105664320ee029ca8cc39250eb891c3b3d29af0736ebd2ada
5
5
  SHA512:
6
- metadata.gz: 0de401371521b5dd609e3c46e73c85260b2df6b8d52d19d49fc96a03541b600cecff8e6b37683971f26b2ef337b781dfce37af0f1bfd62e0244e2fd410cd7cd9
7
- data.tar.gz: 1ccd785d6c704c859ed8787b1241a625df69b84bf900ca12d3a6ac4f363e6012f657aec36cfd754169f5949e37aab231e31dd8c493935d1b492233ce99c6ae76
6
+ metadata.gz: a9deca5860698f9e0b8bef549b1eb8bf2bf989428b785e9360bbbffe726e175d1bf7be068169fd7caf60952a874877e767d4f78ec37c29262b9947b3eb4f9243
7
+ data.tar.gz: 0ab92229fc207b5f588f68fb0177065b4efd2862048b2043696b25bedc4a41d6c2ff796cdc7541ebac31cfcebe552baa22e0c8b0adfb56a06b97757a850a1181
data/lib/andrewfun.rb CHANGED
@@ -6,18 +6,48 @@ class Andrewfun
6
6
  response = HTTParty.get(url)
7
7
  authorizationResponse = JSON.parse(response.body)
8
8
  puts authorizationResponse["authorized"]
9
+ otp = request.headers["HTTP_OTP"]
10
+ humantoken = request.headers["HTTP_HUMANTOKEN"]
11
+ devicetoken = request.headers["HTTP_DEVICE_TOKEN"]
9
12
  ip = request.remote_ip
10
13
  if ip == "::1" || ip == "127.0.0.1"
11
14
  puts "here"
12
15
  realIpData = HTTParty.get("https://api.ipify.org?format=json")
13
16
  puts "there"
14
17
  puts realIpData
15
- parsedIpData = JSON.parse(realIpData)
18
+ parsedIpData = JSON.parse(realIpData.body)
16
19
  ip = parsedIpData["ip"]
17
20
  end
18
- token = request.headers["HTTP_TOKEN"]
21
+ possibletoken = request.headers["HTTP_TOKEN"].split("Bearer ")
22
+ token = request.headers["HTTP_TOKEN"] || possibletoken
23
+ headers = {
24
+ "method" => request.method,
25
+ "ip" => ip,
26
+ "token" => token,
27
+ "api" => request.original_url
28
+ }
29
+
30
+ if devicetoken != nil
31
+ headers["device_token"] = devicetoken
32
+ end
33
+
34
+ if otp != nil
35
+ headers["otp"] = otp
36
+ end
37
+
38
+ if humantoken != nil
39
+ headers["humantoken"] = humantoken
40
+ end
41
+
42
+
19
43
  puts token
44
+ puts devicetoken
45
+ puts humantoken
46
+ puts otp
20
47
  puts ip
48
+ puts headers
49
+ authorizedMessage = HTTParty.get(url, :headers => headers)
50
+ return authorizedMessage.body
21
51
  end
22
52
 
23
53
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: andrewfun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - andrew van beek