fix: jwt expiry not taken from configuration

This commit is contained in:
juancwu 2026-02-17 01:45:29 +00:00
commit 7d3595fdcd
2 changed files with 4 additions and 5 deletions

View file

@ -5,7 +5,6 @@ import (
"log/slog" "log/slog"
"net/http" "net/http"
"strings" "strings"
"time"
"git.juancwu.dev/juancwu/budgit/internal/ctxkeys" "git.juancwu.dev/juancwu/budgit/internal/ctxkeys"
"git.juancwu.dev/juancwu/budgit/internal/service" "git.juancwu.dev/juancwu/budgit/internal/service"
@ -64,7 +63,7 @@ func (h *authHandler) LoginWithPassword(w http.ResponseWriter, r *http.Request)
return return
} }
h.authService.SetJWTCookie(w, jwtToken, time.Now().Add(7*24*time.Hour)) h.authService.SetJWTCookie(w, jwtToken)
// Check for pending invite // Check for pending invite
inviteCookie, err := r.Cookie("pending_invite") inviteCookie, err := r.Cookie("pending_invite")
@ -153,7 +152,7 @@ func (h *authHandler) VerifyMagicLink(w http.ResponseWriter, r *http.Request) {
return return
} }
h.authService.SetJWTCookie(w, jwtToken, time.Now().Add(7*24*time.Hour)) h.authService.SetJWTCookie(w, jwtToken)
// Check for pending invite // Check for pending invite
inviteCookie, err := r.Cookie("pending_invite") inviteCookie, err := r.Cookie("pending_invite")

View file

@ -190,11 +190,11 @@ func (s *AuthService) VerifyJWT(tokenString string) (jwt.MapClaims, error) {
return nil, fmt.Errorf("invalid token") return nil, fmt.Errorf("invalid token")
} }
func (s *AuthService) SetJWTCookie(w http.ResponseWriter, token string, expiry time.Time) { func (s *AuthService) SetJWTCookie(w http.ResponseWriter, token string) {
http.SetCookie(w, &http.Cookie{ http.SetCookie(w, &http.Cookie{
Name: "auth_token", Name: "auth_token",
Value: token, Value: token,
Expires: expiry, Expires: time.Now().Add(s.jwtExpiry),
Path: "/", Path: "/",
HttpOnly: true, HttpOnly: true,
Secure: s.isProduction, Secure: s.isProduction,