Skip to content

Commit 37cfc26

Browse files
committed
add GinParseToken
1 parent 1e9da30 commit 37cfc26

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

mw/gin.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,13 @@ func GinParseToken(secretKey jwt.Keyfunc, whitelist []string) gin.HandlerFunc {
107107
}
108108
}
109109
}
110+
111+
func CreateToken(userID string, accessSecret string, accessExpire int64, platformID int) (string, error) {
112+
claims := tokenverify.BuildClaims(userID, platformID, accessExpire)
113+
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
114+
tokenString, err := token.SignedString([]byte(accessSecret))
115+
if err != nil {
116+
return "", errs.WrapMsg(err, "token.SignedString")
117+
}
118+
return tokenString, nil
119+
}

0 commit comments

Comments
 (0)