Skip to content

Commit

Permalink
Explicitly cast json object to corresponding types
Browse files Browse the repository at this point in the history
Makes it compatible with newer Crystal 0.25.x release
  • Loading branch information
rwojsznis committed Jul 4, 2018
1 parent 8b2deaa commit 861b7f5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/multi_auth/providers/google.cr
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ class MultiAuth::Provider::Google < MultiAuth::Provider

private def primary?(field)
field = json[field]?
return nil if field.nil?
field.each do |item|
return unless field

field.as_a.each do |item|
return item if item["metadata"]["primary"].as_bool?
end

nil
end

Expand Down Expand Up @@ -101,7 +103,7 @@ class MultiAuth::Provider::Google < MultiAuth::Provider
user.phone = primary("phoneNumbers")["canonicalForm"].as_s if primary?("phoneNumbers")
user.description = primary("biographies")["value"].as_s if primary?("biographies")

json["urls"].each do |url|
json["urls"].as_a.each do |url|
urls = {} of String => String
urls[url["type"].as_s] = url["value"].as_s

Expand Down

0 comments on commit 861b7f5

Please sign in to comment.