refactor: move DEFAULT_AUTH_COOKIE_NAME to account

This commit is contained in:
Derrick Hammer 2024-03-17 08:51:59 -04:00
parent 33e644f5c7
commit 5223a44790
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 3 additions and 2 deletions

View File

@ -11,6 +11,8 @@ import (
"github.com/golang-jwt/jwt/v5"
)
const AUTH_COOKIE_NAME = "auth_token"
type JWTPurpose string
type VerifyTokenFunc func(claim *jwt.RegisteredClaims) error

View File

@ -16,7 +16,6 @@ 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
@ -76,7 +75,7 @@ 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 {
if cookie, err := r.Cookie(account.AUTH_COOKIE_NAME); cookie != nil && err == nil {
return cookie.Value
}