sticapi_client 3.0.0 → 3.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e81aef01f67335dc98ecc3836815760957fbdeb1b6fe7e7e0c28e5128a72f8b9
4
- data.tar.gz: 000520ffeb54d0aecdf29c4d62e0b7e6530f086ff69272f470e4bb1162ccbef2
3
+ metadata.gz: e569cede5e4127038d797c4f5241f06a73883dfd41e34c296c022c33b3e208a3
4
+ data.tar.gz: ddb92b5a9a61d55337a7c64820b6321fe69ab08b373dc1126c04bc8b6751a959
5
5
  SHA512:
6
- metadata.gz: 0f502a4f7c80b676b1cc05c2b2afee530e7fb037218a3f9d45d48951e67d5c98834eb7f1c551c0a010d2a464946e7028769fd0edd2cc17ad788d8c99115d31c0
7
- data.tar.gz: a75a05d28e4d2c3a6a3f7ff1f6f39018c344813b82b648622b407ee655873e94c7887233effcb72f69ca9d191dbfeb2dd3e87a8ee0a7da69ef875287be2beddc
6
+ metadata.gz: 360ff3496070858144cc5dac05e0880a5f8f764e14e3eee0240ffed9db8ca683d60cd150d2d3fd7e96eafbbd023d0fa5ddb81b93b76732656cd3b1e641a20282
7
+ data.tar.gz: 79079047830b4c107aa1bf45c5671222d52bba5cbf4f35cf4abd63941c3f910cd74b521b96407c3a805b4a0494a3921526a1985d1a07c13fa3ce631616029c88
@@ -35,44 +35,25 @@ module Devise
35
35
  }
36
36
  token = JWT.encode payload, secret, 'HS256'
37
37
 
38
- uri = URI.parse("#{Sticapi::SticapiClient.instance.uri}/users/log_in")
39
- http = Net::HTTP.new(uri.host, uri.port)
40
- request = Net::HTTP::Post.new(uri.request_uri)
41
- request['Content-Type'] = 'application/json'
42
- request['access-token'] = Sticapi::SticapiClient.instance.access_token
43
- request['client'] = Sticapi::SticapiClient.instance.client
44
- request['uid'] = Sticapi::SticapiClient.instance.uid
45
- request.body = { data: token }.to_json
46
- response = http.request(request)
47
- Sticapi::SticapiClient.instance.update_token(response)
38
+ data = Sticapi::SticapiClient.instance.sticapi_request("/users/log_in", data: token)
48
39
 
49
- case response
50
- when Net::HTTPSuccess
51
- data = JSON.parse(response.body)
52
- if data['user']
53
- unless user = User.find_by(username: data['user']['username'])
54
- user = User.new
55
- user.name = data['user']['name'] if user.respond_to? :name
56
- user.username = data['user']['username'] if user.respond_to? :username
57
- user.email = data['user']['email']
58
- user.cpf = data['user']['cpf'] if user.respond_to? :cpf
59
- end
60
- user.password = params[:user][:password] if user.respond_to? :password
61
- user.password_confirmation = params[:user][:password] if user.respond_to? :password_confirmation
62
- user.unities = data['user']['unities'] if user.respond_to? :unities
63
- user.skip_confirmation! if user.respond_to? 'skip_confirmation!'
64
- user.save
65
- success!(user)
66
- return
67
- else
68
- return fail(:invalid)
69
- end
70
- when Net::HTTPUnauthorized
71
- return fail(:invalid)
72
- when Net::HTTPServerError
73
- return fail(:invalid)
74
- else
75
- return fail(:invalid)
40
+ if data['user']
41
+ unless user = User.find_by(username: data['user']['username'])
42
+ user = User.new
43
+ user.name = data['user']['name'] if user.respond_to? :name
44
+ user.username = data['user']['username'] if user.respond_to? :username
45
+ user.email = data['user']['email']
46
+ user.cpf = data['user']['cpf'] if user.respond_to? :cpf
47
+ end
48
+ user.password = params[:user][:password] if user.respond_to? :password
49
+ user.password_confirmation = params[:user][:password] if user.respond_to? :password_confirmation
50
+ user.unities = data['user']['unities'] if user.respond_to? :unities
51
+ user.skip_confirmation! if user.respond_to? 'skip_confirmation!'
52
+ user.save
53
+ success!(user)
54
+ return
55
+ else
56
+ return fail(:invalid)
76
57
  end
77
58
  end
78
59
  else
@@ -1,3 +1,3 @@
1
1
  module SticapiClient
2
- VERSION = "3.0.0"
2
+ VERSION = "3.0.1"
3
3
  end
@@ -57,6 +57,7 @@ module Sticapi
57
57
  http = Net::HTTP.new(uri.host, uri.port)
58
58
  http.use_ssl = @ssl
59
59
  request = Net::HTTP::Post.new(uri.request_uri)
60
+ request['Content-Type'] = 'application/json'
60
61
  request['email'] = @user
61
62
  request['password'] = @password
62
63
  response = http.request(request)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sticapi_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Viana
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-06 00:00:00.000000000 Z
11
+ date: 2022-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails