Commit f31b9072af098e55611223aab2d59559d7b4e97a

Authored by Jeff Lai
1 parent 053e577d
Exists in master

Fix bug

Showing 1 changed file with 6 additions and 4 deletions   Show diff stats
lib/dingtalk/client.rb
... ... @@ -9,11 +9,13 @@ module Dingtalk
9 9 end
10 10  
11 11 def response_json(return_str)
  12 + the_timestamp = timestamp
  13 + the_nonce = nonce
12 14 {
13   - msg_signature: signature(return_str),
  15 + msg_signature: signature(return_str, the_timestamp, the_nonce),
14 16 encrypt: encrypt(return_str),
15   - timeStamp: timestamp,
16   - nonce: nonce
  17 + timeStamp: the_timestamp,
  18 + nonce: the_nonce
17 19 }
18 20 end
19 21  
... ... @@ -21,7 +23,7 @@ module Dingtalk
21 23 encrypt = Dingtalk::Prpcrypt.encrypt(aes_key, return_str, Dingtalk.suite_key)
22 24 end
23 25  
24   - def signature(return_str)
  26 + def signature(return_str, timestamp, nonce)
25 27 sort_params = [Dingtalk.suite_token, timestamp, nonce, encrypt(return_str)].sort.join
26 28 Digest::SHA1.hexdigest(sort_params)
27 29 end
... ...