Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/multi_auth/providers/facebook.cr
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class MultiAuth::Provider::Facebook < MultiAuth::Provider
user.last_name = fb_user.last_name
user.location = fb_user.location
user.description = fb_user.about
user.image = fb_user.picture[:data][:url]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code will raise an exception if fb_user.picture is nil, right? could we avoid it?

user.gender = fb_user.gender

urls = {} of String => String
urls["web"] = fb_user.website.as(String) if fb_user.website
Expand All @@ -33,8 +35,9 @@ class MultiAuth::Provider::Facebook < MultiAuth::Provider

property raw_json : String?
property access_token : OAuth2::AccessToken?
property picture_url : String?
property picture : NamedTuple( data: NamedTuple( url: String, height: Int64, width: Int64, is_silhouette: Bool))

property gender : String?
property id : String
property name : String
property last_name : String?
Expand All @@ -50,7 +53,7 @@ class MultiAuth::Provider::Facebook < MultiAuth::Provider
api = HTTP::Client.new("graph.facebook.com", tls: true)
access_token.authenticate(api)

raw_json = api.get("/v2.9/me?fields=id,name,last_name,first_name,email,location,about,website").body
raw_json = api.get("/v2.9/me?fields=gender,picture,id,name,last_name,first_name,email,location,about,website").body

fb_user = FbUser.from_json(raw_json)
fb_user.access_token = access_token
Expand Down
1 change: 1 addition & 0 deletions src/multi_auth/user.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class MultiAuth::User
getter access_token : OAuth::AccessToken | OAuth2::AccessToken

property email : String?
property gender : String?
property nickname : String?
property first_name : String?
property last_name : String?
Expand Down