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

@@ -11,8 +11,8 @@ import (
"projectreshoot/internal/models"
"projectreshoot/pkg/config"
"projectreshoot/pkg/contexts"
"projectreshoot/pkg/cookies"
"git.haelnorr.com/h/golib/cookies"
"git.haelnorr.com/h/golib/hlog"
"git.haelnorr.com/h/golib/jwt"
"github.com/pkg/errors"
@@ -38,7 +38,7 @@ func refreshAuthTokens(
}[ref.TTL]
// Set fresh to true because new tokens coming from refresh request
err = cookies.SetTokenCookies(w, req, config, tokenGen, user, false, rememberMe)
err = jwt.SetTokenCookies(w, req, tokenGen, user.ID, false, rememberMe, config.SSL)
if err != nil {
return nil, errors.Wrap(err, "cookies.SetTokenCookies")
}
@@ -60,7 +60,7 @@ func getAuthenticatedUser(
r *http.Request,
) (*contexts.AuthenticatedUser, error) {
// Get token strings from cookies
atStr, rtStr := cookies.GetTokenStrings(r)
atStr, rtStr := jwt.GetTokenCookies(r)
if atStr == "" && rtStr == "" {
return nil, errors.New("No token strings provided")
}