Add timestamp to tokens

This commit is contained in:
rxdn 2021-01-15 22:30:24 +00:00
parent d05ea20d60
commit 80ae56fc7a

View File

@ -8,6 +8,7 @@ import (
"github.com/gin-gonic/contrib/sessions" "github.com/gin-gonic/contrib/sessions"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"strconv" "strconv"
"time"
) )
func TokenHandler(ctx *gin.Context) { func TokenHandler(ctx *gin.Context) {
@ -16,6 +17,7 @@ func TokenHandler(ctx *gin.Context) {
token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{ token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
"userid": strconv.FormatUint(userId, 10), "userid": strconv.FormatUint(userId, 10),
"timestamp": time.Now(),
}) })
str, err := token.SignedString([]byte(config.Conf.Server.Secret)) str, err := token.SignedString([]byte(config.Conf.Server.Secret))