oauth_twitter_callback.go: add better error handling
This commit is contained in:
parent
be197f2b69
commit
c30da607cb
@ -58,12 +58,28 @@ func twitterCallbackHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
name := res["name"].(string)
|
if res["email"] == nil {
|
||||||
handle := res["screen_name"].(string)
|
fmt.Fprintf(w, "Error: no email address returned by Twitter")
|
||||||
link := "https://twitter.com/" + handle
|
return
|
||||||
photo := "https://twitter.com/" + handle + "/profile_image"
|
}
|
||||||
|
|
||||||
email := res["email"].(string)
|
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)
|
c, err := commenterGetByEmail("twitter", email)
|
||||||
if err != nil && err != errorNoSuchCommenter {
|
if err != nil && err != errorNoSuchCommenter {
|
||||||
fmt.Fprintf(w, "Error: %s", err.Error())
|
fmt.Fprintf(w, "Error: %s", err.Error())
|
||||||
|
Loading…
Reference in New Issue
Block a user