From 37ac0a471aa4bd9d4e8b0b7db49f3635bd974571 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 15 Apr 2015 15:04:16 +1000 Subject: [PATCH] correct missing cookie behavior --- main.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index c79822c..a05ea96 100644 --- a/main.go +++ b/main.go @@ -1,17 +1,13 @@ package main import ( - // "flag" - "fmt" - // "html" "code.google.com/p/go-uuid/uuid" "crypto/hmac" "crypto/sha256" "encoding/base64" "encoding/hex" - // "fmt" + "fmt" "github.com/golang/groupcache/lru" - // "html" "github.com/namsral/flag" "log" "net/http" @@ -85,12 +81,11 @@ func envOrFlag(name, help string) string { func redirectIfCookieMissing(handler http.Handler, ssoSecret, cookieSecret, ssoUri string) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - cookie, _ := r.Cookie("__discourse_proxy") + cookie, err := r.Cookie("__discourse_proxy") var username string - var err error - if cookie != nil { + if err == nil && cookie != nil { username, err = parseCookie(cookie.Value, cookieSecret) }