horse_power 0.8.2 → 0.8.3

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
  SHA1:
3
- metadata.gz: 9442e28cc073d758e9835dceb9193ff27e48534f
4
- data.tar.gz: 5ae049d0df4c3869d9a366900dc301dd0bee3cc1
3
+ metadata.gz: 11e5b8359c276a69382c43a467a1ee120f97dc1f
4
+ data.tar.gz: e7047dbdde2d4bbacfe43acf58b5a9247c2bb5a5
5
5
  SHA512:
6
- metadata.gz: d2fbb5c843e3e78e9d1e5b8273696a3189636c889004d4da2f206869f71e7e5eb9cfae6873fcd490d251ffc5ee764252e71ee5e8e71306621dad9e28e73a2288
7
- data.tar.gz: 794855f0154eed79f46daac8a8b20f8a8e597696b0f160c31f384a831088d31aa33013f402e539dbf0f7fee1cdd126cd4296da287da8b13c7c97b286de1fed8e
6
+ metadata.gz: 80e6e5f6920474876c9af613824bba5d75f235655762de48c81672f6f585923dd9a5c337ff2add1c54440d3c890c3085175d52f0a1800940d83df3dd3ad01700
7
+ data.tar.gz: c3c4fd4d3318b4c3f7f395e58f36c4439b888795f2ead55b967487080fd0597a7630be9c877dd2517abf4720370a54b7f4149b04fa9427e3fed4a482a9eea3dd
@@ -27,14 +27,33 @@ but the db token was not yet expired.
27
27
  instance_hash["current_token"] = nil
28
28
  instance_hash["auth_token"] = token["auth_token"]
29
29
  return instance_hash
30
- rescue ::JWT::DecodeError, ::JWT::ExpiredSignature
31
- # Try Arcadex token
32
- instance_hash = ::Arcadex::Authentication.get_instance(params,request,::Settings.token_header)
33
- if !instance_hash.nil?
34
- instance_hash["auth_token"] = nil
35
- end
36
- return instance_hash
30
+ rescue ::JWT::ExpiredSignature
31
+ return handle_expired(auth_token_obj)
32
+ rescue ::JWT::DecodeError
33
+ return handle_abnormal(params,request)
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ def self.handle_expired(auth_token_obj)
40
+ # Token expired, destroy arcadex token
41
+ jwt = ::JWT.decode(auth_token_obj,::Rails.application.secrets.secret_key_base,true,{verify_expiration: false})
42
+ token = jwt[0]
43
+ db_token = ::Arcadex::Find.find_token_by_auth_token(token["auth_token"])
44
+ if !db_token.nil?
45
+ db_token.destroy
46
+ end
47
+ return nil
48
+ end
49
+
50
+ def self.handle_abnormal(params,request)
51
+ # Try Arcadex token
52
+ instance_hash = ::Arcadex::Authentication.get_instance(params,request,::Settings.token_header)
53
+ if !instance_hash.nil?
54
+ instance_hash["auth_token"] = nil
37
55
  end
56
+ return instance_hash
38
57
  end
39
58
 
40
59
  end
@@ -1,3 +1,3 @@
1
1
  module HorsePower
2
- VERSION = "0.8.2"
2
+ VERSION = "0.8.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: horse_power
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cleophus Robinson IV