authsignal-ruby 0.1.5 → 0.1.6

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
  SHA256:
3
- metadata.gz: f77d1646d619436a3c5e25b76be690252c3f4bf2dcb7588ea09cae4c11283017
4
- data.tar.gz: 67ad78b10cb51e07b2f2726a4a8ad74ba094eacd37b0acd6436a4e89f9b7d306
3
+ metadata.gz: 553049be926d596da10a2e826338db41bd2a9a8a3fa2dbbf545b4b7d2850d828
4
+ data.tar.gz: 0d510dfa15063a1730f6490d93aed9614f4e88167eb44c76309460632d9cc499
5
5
  SHA512:
6
- metadata.gz: a02302caa711e51e25877b73e2b83c074ebd868e9f43eec42d0b29046f0f62a99ec07a930e73eb4204cffab72992831395e36b8f6d6a6a01e010536e2c550286
7
- data.tar.gz: 5791b35e320bc81ca7f7137f736f847f7b2eae79073afe9eed0c91376e557dd63c2e0d952bf42d2d15dd04eac3c6827e003283e63e0f95f3cb681d4d3714ee3e
6
+ metadata.gz: 90bbb9bb3d7c738995816d34a1cdd7a251edb593dca9f87698d1bcddcbcc4da77d4eb529b17297ed322f2a6bd564909eeb8cf7b6722b4200acacd09e139c7877
7
+ data.tar.gz: 1dc7095f53fb925f7702207b34a13bd052e9d4b835ea4880968d54027b70254aa3b69332debbc8c407994d918eb3e653f96f58741fd0eeac77c338114d247021
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- authsignal-ruby (0.1.5)
4
+ authsignal-ruby (0.1.6)
5
5
  httparty (~> 0.21.0)
6
6
 
7
7
  GEM
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Authsignal
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.6"
5
5
  end
data/lib/authsignal.rb CHANGED
@@ -69,35 +69,33 @@ module Authsignal
69
69
  false
70
70
  end
71
71
 
72
- def validate_challenge(request)
73
- token = request[:token]
74
-
72
+ def validate_challenge(user_id:, token:)
75
73
  begin
76
74
  decoded_token = JWT.decode(token, Authsignal.configuration.api_secret_key)[0]
77
75
  rescue JWT::DecodeError
78
76
  puts 'Token verification failed'
79
77
  end
80
78
 
81
- user_id = decoded_token["other"]["userId"]
79
+ decoded_user_id = decoded_token["other"]["userId"]
82
80
  action_code = decoded_token["other"]["actionCode"]
83
81
  idempotency_key = decoded_token["other"]["idempotencyKey"]
84
82
 
85
- if request[:userId] && request[:userId] != user_id
86
- return { user_id: user_id, success: false, state: nil }
83
+ if user_id != decoded_user_id
84
+ return { user_id: decoded_user_id, success: false, state: nil }
87
85
  end
88
86
 
89
87
  if action_code && idempotency_key
90
- action_result = get_action(user_id: user_id, action_code: action_code, idempotency_key: idempotency_key)
88
+ action_result = get_action(user_id: decoded_user_id, action_code: action_code, idempotency_key: idempotency_key)
91
89
 
92
90
  if action_result
93
91
  state = action_result[:state]
94
92
  success = state == "CHALLENGE_SUCCEEDED"
95
93
 
96
- return { user_id: user_id, success: success, state: state, action: action_code }
94
+ return { user_id: decoded_user_id, success: success, state: state, action: action_code }
97
95
  end
98
96
  end
99
97
 
100
- { user_id: user_id, success: false, state: nil }
98
+ { user_id: decoded_user_id, success: false, state: nil }
101
99
  end
102
100
 
103
101
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authsignal-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - justinsoong