oauth_google_callback.go: fix potential nil panic
This commit is contained in:
parent
55f24b2de2
commit
514535a607
@ -39,7 +39,14 @@ func googleCallbackHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c, err := commenterGetByEmail("google", user["email"].(string))
|
if user["email"] == nil {
|
||||||
|
fmt.Fprintf(w, "Error: no email address returned by Github")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
email := user["email"].(string)
|
||||||
|
|
||||||
|
c, err := commenterGetByEmail("google", 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())
|
||||||
return
|
return
|
||||||
@ -49,14 +56,6 @@ func googleCallbackHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// TODO: in case of returning users, update the information we have on record?
|
// TODO: in case of returning users, update the information we have on record?
|
||||||
if err == errorNoSuchCommenter {
|
if err == errorNoSuchCommenter {
|
||||||
var email string
|
|
||||||
if _, ok := user["email"]; ok {
|
|
||||||
email = user["email"].(string)
|
|
||||||
} else {
|
|
||||||
fmt.Fprintf(w, "Error: %s", errorInvalidEmail.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var link string
|
var link string
|
||||||
if val, ok := user["link"]; ok {
|
if val, ok := user["link"]; ok {
|
||||||
link = val.(string)
|
link = val.(string)
|
||||||
|
Loading…
Reference in New Issue
Block a user