migrated out cookies module

This commit is contained in:
2026-01-02 18:37:01 +11:00
parent 8f6b4b0026
commit 6dd80ee7b6
12 changed files with 73 additions and 221 deletions

View File

@@ -9,7 +9,6 @@ import (
"projectreshoot/internal/view/component/form"
"projectreshoot/pkg/config"
"projectreshoot/pkg/contexts"
"projectreshoot/pkg/cookies"
"git.haelnorr.com/h/golib/hlog"
"git.haelnorr.com/h/golib/jwt"
@@ -24,7 +23,7 @@ func getTokens(
r *http.Request,
) (*jwt.AccessToken, *jwt.RefreshToken, error) {
// get the existing tokens from the cookies
atStr, rtStr := cookies.GetTokenStrings(r)
atStr, rtStr := jwt.GetTokenCookies(r)
aT, err := tokenGen.ValidateAccess(tx, atStr)
if err != nil {
return nil, nil, errors.Wrap(err, "tokenGen.ValidateAccess")
@@ -71,7 +70,7 @@ func refreshTokens(
}[aT.TTL]
// issue new tokens for the user
user := contexts.GetUser(r.Context())
err = cookies.SetTokenCookies(w, r, config, tokenGen, user.User, true, rememberMe)
err = jwt.SetTokenCookies(w, r, tokenGen, user.ID, true, rememberMe, config.SSL)
if err != nil {
return errors.Wrap(err, "cookies.SetTokenCookies")
}