added logging to handler to identify errors
This commit is contained in:
parent
beb009388c
commit
7a0a2235b9
1 changed files with 8 additions and 4 deletions
|
@ -34,7 +34,8 @@ func GetLogin(c web.C, w http.ResponseWriter, r *http.Request) {
|
|||
// authenticate the user
|
||||
login, err := remote.Authorize(w, r)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
log.Println(err)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
} else if login == nil {
|
||||
// in this case we probably just redirected
|
||||
|
@ -63,7 +64,8 @@ func GetLogin(c web.C, w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// insert the user into the database
|
||||
if err := datastore.PostUser(ctx, u); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
log.Println(err)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -82,7 +84,8 @@ func GetLogin(c web.C, w http.ResponseWriter, r *http.Request) {
|
|||
u.SetEmail(login.Email)
|
||||
u.Syncing = true //u.IsStale() // todo (badrydzewski) should not always sync
|
||||
if err := datastore.PutUser(ctx, u); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
log.Println(err)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -147,7 +150,8 @@ func GetLogin(c web.C, w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
token, err := session.GenerateToken(ctx, r, u)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
log.Println(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
redirect = redirect + "#access_token=" + token
|
||||
|
|
Loading…
Reference in a new issue