diff --git a/api/oauth_twitter_callback.go b/api/oauth_twitter_callback.go index f97d864..6689d3d 100644 --- a/api/oauth_twitter_callback.go +++ b/api/oauth_twitter_callback.go @@ -58,12 +58,28 @@ func twitterCallbackHandler(w http.ResponseWriter, r *http.Request) { return } - name := res["name"].(string) - handle := res["screen_name"].(string) - link := "https://twitter.com/" + handle - photo := "https://twitter.com/" + handle + "/profile_image" + if res["email"] == nil { + fmt.Fprintf(w, "Error: no email address returned by Twitter") + return + } + email := res["email"].(string) + if res["name"] == nil { + fmt.Fprintf(w, "Error: no name returned by Twitter") + return + } + + name := res["name"].(string) + + link := "undefined" + photo := "undefined" + if res["handle"] != nil { + handle := res["screen_name"].(string) + link = "https://twitter.com/" + handle + photo = "https://twitter.com/" + handle + "/profile_image" + } + c, err := commenterGetByEmail("twitter", email) if err != nil && err != errorNoSuchCommenter { fmt.Fprintf(w, "Error: %s", err.Error())