Add timestamp to tokens
This commit is contained in:
parent
d05ea20d60
commit
80ae56fc7a
@ -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))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user