Flip verifyAuthCode if

This commit is contained in:
Peter Stuifzand 2020-07-27 22:41:15 +02:00
parent e0d337c850
commit 45616fa60e
Signed by: peter
GPG Key ID: 374322D56E5209E8
2 changed files with 11 additions and 12 deletions

View File

@ -51,7 +51,6 @@ func cachedCheckAuthToken(conn redis.Conn, header string, tokenEndpoint string,
}
func checkAuthToken(header string, tokenEndpoint string, token *auth.TokenResponse) (bool, error) {
req, err := buildValidateAuthTokenRequest(tokenEndpoint, header)
if err != nil {
return false, err

View File

@ -177,19 +177,19 @@ func verifyAuthCode(code, redirectURI, authEndpoint, clientID string) (bool, *au
defer resp.Body.Close()
if resp.StatusCode == 200 {
input := io.TeeReader(resp.Body, os.Stderr)
dec := json.NewDecoder(input)
var authResponse authResponse
err = dec.Decode(&authResponse)
if err != nil {
return false, nil, fmt.Errorf("while verifying authentication response from %s: %s", authEndpoint, err)
}
return true, &authResponse, nil
if resp.StatusCode != 200 {
return false, nil, fmt.Errorf("HTTP response code from authorization_endpoint (%s) %d", authEndpoint, resp.StatusCode)
}
return false, nil, fmt.Errorf("HTTP response code from authorization_endpoint (%s) %d", authEndpoint, resp.StatusCode)
input := io.TeeReader(resp.Body, os.Stderr)
dec := json.NewDecoder(input)
var authResponse authResponse
err = dec.Decode(&authResponse)
if err != nil {
return false, nil, fmt.Errorf("while verifying authentication response from %s: %s", authEndpoint, err)
}
return true, &authResponse, nil
}
func isLoggedIn(backend *memoryBackend, sess *session) bool {