Skip to content

Commit

Permalink
specify key of field for NumericDate
Browse files Browse the repository at this point in the history
  • Loading branch information
YiranDuan721 committed Jan 21, 2024
1 parent 90af7b2 commit 02ffcfd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/middlewares.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ func InitContext(daoWrapper dao.DaoWrapper) gin.HandlerFunc {
// but only when the token has not been updated during the last 1 hour
if claims.RememberMe && time.Since(claims.UpdatedAt.Time).Hours() > MinUpdateIntervalInHours {
// remove jwt cookie older than MaxTokenAgeWithRefreshInDays
expiresAt := &jwt.NumericDate{time.Now().Add(time.Hour * 24 * MaxTokenAgeInDays)}
expiresAt := &jwt.NumericDate{Time: time.Now().Add(time.Hour * 24 * MaxTokenAgeInDays)}
if expiresAt.Sub(claims.IssuedAt.Time).Hours() > MaxTokenLifetimeWithRememberMeInDays*24 {
c.SetCookie("jwt", "", -1, "/", "", false, true)
return
}
claims.ExpiresAt = expiresAt
claims.UpdatedAt = &jwt.NumericDate{time.Now()}
claims.UpdatedAt = &jwt.NumericDate{Time: time.Now()}

token = jwt.NewWithClaims(token.Method, claims)
signedToken, err := token.SignedString(Cfg.GetJWTKey())
Expand Down

0 comments on commit 02ffcfd

Please sign in to comment.