some error handling

This commit is contained in:
Livio Amstutz 2019-11-28 08:56:53 +01:00
parent 8ee38d2ec8
commit 10d671956a
3 changed files with 32 additions and 21 deletions

View file

@ -1,7 +1,6 @@
package op
import (
"encoding/json"
"errors"
"net/http"
"net/url"
@ -234,16 +233,11 @@ func (p *DefaultOP) HandleAuthorizeCallback(w http.ResponseWriter, r *http.Reque
func (p *DefaultOP) HandleExchange(w http.ResponseWriter, r *http.Request) {
reqType := r.FormValue("grant_type")
if reqType == "" {
ExchangeRequestError(w, r, nil, ErrInvalidRequest("grant_type missing"))
ExchangeRequestError(w, r, ErrInvalidRequest("grant_type missing"))
return
}
if reqType == string(oidc.GrantTypeCode) {
token, err := CodeExchange(w, r, p.storage, p.decoder)
if err != nil {
}
b, _ := json.Marshal(token)
w.Write(b)
CodeExchange(w, r, p.storage, p.decoder)
return
}
p.handleTokenExchange(w, r)