diff --git a/api/middleware/middleware.go b/api/middleware/middleware.go index 05ec632..139f51a 100644 --- a/api/middleware/middleware.go +++ b/api/middleware/middleware.go @@ -16,6 +16,7 @@ import ( ) const DEFAULT_AUTH_CONTEXT_KEY = "user_id" +const DEFAULT_AUTH_COOKIE_NAME = "auth_token" type JapeMiddlewareFunc func(jape.Handler) jape.Handler type HttpMiddlewareFunc func(http.Handler) http.Handler @@ -75,6 +76,10 @@ func FindAuthToken(r *http.Request, cookieName string, queryParam string) string return cookie.Value } + if cookie, err := r.Cookie(DEFAULT_AUTH_COOKIE_NAME); cookie != nil && err == nil { + return cookie.Value + } + return r.FormValue(queryParam) }