plyom_user 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc5085481483dbecbb0daa0372accc3a02b2900f
4
- data.tar.gz: ec254c0cac37998cfa235dea0a59a112bf78f3a1
3
+ metadata.gz: 4b8a8c44d225aaad74f74578775a0a10f6380c3d
4
+ data.tar.gz: 9ce1f5881b91d3edb198b45a8c6d5d89b568f24e
5
5
  SHA512:
6
- metadata.gz: 472d6e7254fd05310550a69014b30ed8c931f66e383a16bca2ac0f69fae6819d2de5bf5c3ef8966fa6711d8756e3b78c0fe063a056db2e8fea03f82b04a695d5
7
- data.tar.gz: d3333e3afca6000ae3228e887cb0cff9d8ba364df5d9422130ddf1a067c7b13b7220de955068f1800a77f7d5ebb04f79104e3db2f3ac6ea293c41d759da6d502
6
+ metadata.gz: 27596ced5f164c93c928fffc722ad07fbb012441747151cfe357ec89d98e1ba7e11815a06f2814d74f3e08908a2e393e61ccdaf79bc1f5f063a0c055e7003424
7
+ data.tar.gz: 59130e7dee783544c56ca392860ce21d40a359b6ac666cc52e270944ced9c2eaff401fd9f6c07625d9589b3a580cd42ff5bae2ad179be62ab314a43aea6bf9aa
data/lib/plyom_user.rb CHANGED
@@ -72,4 +72,52 @@ module Plyom
72
72
  host + path
73
73
  end
74
74
  end
75
+
76
+ class Authentication
77
+
78
+ def initialize(params)
79
+ @params = params
80
+ end
81
+
82
+ def authenticated?(token)
83
+ auth_token = { "Authorization" => "Token token=\"#{token}\"" }
84
+ paramters = {username_email: @params[:username], password: @params[:password]}
85
+ response = HTTParty.get("#{uri}authentication", headers: auth_token, query: paramters)
86
+ result = JSON.parse(response.body)
87
+ if result["success"]
88
+ @token = result["token"]
89
+ @validation = 1
90
+ true
91
+ else
92
+ false
93
+ end
94
+ end
95
+
96
+ def validation
97
+ @validation
98
+ end
99
+
100
+ def check_token(token)
101
+ paramters = {token: @token}
102
+ auth_token = { "Authorization" => "Token token=\"#{token}\"" }
103
+ response = HTTParty.get("#{uri}token_validation", headers: auth_token, query: paramters)
104
+ response.body
105
+ end
106
+
107
+ def self.validates(validation)
108
+ if validation == 1
109
+ true
110
+ else
111
+ false
112
+ end
113
+ end
114
+
115
+ private
116
+ def self.uri
117
+ host = ENV["plyom_user_host"]
118
+ path = "/api/"
119
+ host + path
120
+ end
121
+
122
+ end
75
123
  end
@@ -1,3 +1,3 @@
1
1
  module PlyomUser
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plyom_user
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernando Pileggi