u
This commit is contained in:
1 parent
1b1a54f7dd
commit
fc005e0fb4
22 files changed
+300
-193
No files matched your search
@@ -46,12 +46,14 @@ func CreateToken(ctx context.Context, userID int64) (string, error) {
|
||||
|
||||
// VerifyToken 校验 token 并返回 claims
|
||||
func VerifyToken(ctx context.Context, tokenString string) (*CustomClaims, bool) {
|
||||
if tokenString == "" || manager == nil {
|
||||
if tokenString == "" {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
m := getManager()
|
||||
|
||||
token, err := jwt.ParseWithClaims(tokenString, &CustomClaims{}, func(token *jwt.Token) (interface{}, error) {
|
||||
return []byte(manager.secret), nil
|
||||
return []byte(m.secret), nil
|
||||
})
|
||||
|
||||
if err != nil || !token.Valid {
|
||||
|
||||
Reference in new issue
Block a user