refactor: fall back and check for DEFAULT_AUTH_COOKIE_NAME
This commit is contained in:
parent
193871f083
commit
b03e6815e2
|
@ -16,6 +16,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const DEFAULT_AUTH_CONTEXT_KEY = "user_id"
|
const DEFAULT_AUTH_CONTEXT_KEY = "user_id"
|
||||||
|
const DEFAULT_AUTH_COOKIE_NAME = "auth_token"
|
||||||
|
|
||||||
type JapeMiddlewareFunc func(jape.Handler) jape.Handler
|
type JapeMiddlewareFunc func(jape.Handler) jape.Handler
|
||||||
type HttpMiddlewareFunc func(http.Handler) http.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
|
return cookie.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cookie, err := r.Cookie(DEFAULT_AUTH_COOKIE_NAME); cookie != nil && err == nil {
|
||||||
|
return cookie.Value
|
||||||
|
}
|
||||||
|
|
||||||
return r.FormValue(queryParam)
|
return r.FormValue(queryParam)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue