Skip to content

Commit 113fbdf

Browse files
committedJul 15, 2024··
#122 enable integer
1 parent af62967 commit 113fbdf

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed
 

‎lib/glogin/cookie.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ def initialize(json, secret, context = '')
9292
raise 'JSON can\'t be nil' if json.nil?
9393
raise 'JSON must contain "id" key' if json['id'].nil?
9494
json.each do |k, v|
95-
raise "Key #{k} is not a string" unless k.is_a?(String)
96-
raise "Key #{k} is not allowed" unless %w[id login avatar_url bearer].include?(k)
97-
raise "Value #{v} is not a string" unless v.is_a?(String)
95+
raise "The key #{k} is not a string" unless k.is_a?(String)
96+
raise "The key #{k} is not allowed" unless %w[id login avatar_url bearer].include?(k)
97+
raise "The value '#{v}' of #{k} is not String or Integer" unless v.is_a?(String) || v.is_a?(Integer)
9898
end
9999
@id = json['id']
100100
@login = json['login'] || ''

‎test/glogin/test_cookie.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_encrypts_and_decrypts
3030
user = GLogin::Cookie::Closed.new(
3131
GLogin::Cookie::Open.new(
3232
JSON.parse(
33-
"{\"id\":\"123\",
33+
"{\"id\":123,
3434
\"login\":\"yegor256\",
3535
\"avatar_url\":\"https://avatars1.githubusercontent.com/u/526301\"}"
3636
),

0 commit comments

Comments
 (0)
Please sign in to comment.