fix: sesión sin vencimiento práctico (90 años JWT + cookie persistente)

- JWT exp: 1 año → 90 años
- Cookie Verify-Rest-Token: sin MaxAge (session cookie) → MaxAge 90 años
- Session store: 1 año → 90 años

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-09 20:20:33 -05:00
co-authored by Claude Sonnet 4.6
parent b3b6f6705d
commit 2ee5e2ea83
2 changed files with 6 additions and 4 deletions
+3 -1
View File
@@ -21,10 +21,11 @@ func (t *Token) CreateToken(c *fiber.Ctx, userID uint, secret string, expire ...
claims := token.Claims.(jwt.MapClaims)
claims["id"] = userID
const ninetyYears = int64(90 * 365 * 24 * 3600)
if len(expire) > 0 {
t.Expire = expire[0]
} else {
t.Expire = 31536000 // 1 año por defecto si no se configura
t.Expire = ninetyYears
}
expiresIn := time.Now().Add(time.Duration(t.Expire) * time.Second).Unix()
claims["exp"] = expiresIn
@@ -37,6 +38,7 @@ func (t *Token) CreateToken(c *fiber.Ctx, userID uint, secret string, expire ...
c.Cookie(&fiber.Cookie{
Name: "Verify-Rest-Token",
Value: tokenHash,
MaxAge: int(ninetyYears),
Secure: false,
HTTPOnly: true,
})