parent
4657dd9505
commit
99f88d2fb8
|
|
@ -183,9 +183,14 @@ func requestLoginCookie(r *http.Request) (User, bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCookie(key string, r *http.Request) (string, bool) {
|
func getCookie(key string, r *http.Request) (string, bool) {
|
||||||
cookie, err := r.Cookie(key)
|
var cookie *http.Cookie
|
||||||
if err != nil {
|
cookies := r.Cookies()
|
||||||
log.Printf("err getting cookie %s: %v: %+v", key, err, r.Cookies())
|
for i := range cookies {
|
||||||
|
if cookies[i].Name == key && (cookies[i].Expires.IsZero() || time.Now().Before(cookies[i].Expires)) {
|
||||||
|
cookie = cookies[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if cookie == nil {
|
||||||
return "", false
|
return "", false
|
||||||
}
|
}
|
||||||
return cookie.Value, cookie.Expires.IsZero() || time.Now().Before(cookie.Expires)
|
return cookie.Value, cookie.Expires.IsZero() || time.Now().Before(cookie.Expires)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue