Browse Source

delete expired checking

Paul 6 years ago
parent
commit
41c11015b7
1 changed files with 3 additions and 18 deletions
  1. 3
    18
      middleware/auth/auth.go

+ 3
- 18
middleware/auth/auth.go View File

@@ -52,25 +52,10 @@ func Auth(authKey string, session Session) gin.HandlerFunc {
52 52
 		}
53 53
 
54 54
 		if mapClaims, ok := token.Claims.(jwt.MapClaims); ok {
55
-			if expired, ok := mapClaims[ctxRequestTokenExpired].(float64); ok {
56
-				if expired == 0 && tokenFromCookie == "" {
57
-					if session.DeleteJwtToken(token.Raw) {
58
-						ctx.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"msg": "auth failed, token expired"})
59
-					} else {
60
-						ctx.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"msg": "auth failed, delete server token failed"})
61
-					}
62
-
63
-					return
64
-				}
65
-
66
-				if uid, ok := mapClaims[CtxRequestHeaderUserId].(float64); ok {
67
-					ctx.Set(CtxRequestHeaderUserId, int64(uid))
68
-				} else {
69
-					ctx.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"msg": "auth failed, mapClaims[CtxRequestHeaderUserId].(float64) error"})
70
-					return
71
-				}
55
+			if uid, ok := mapClaims[CtxRequestHeaderUserId].(float64); ok {
56
+				ctx.Set(CtxRequestHeaderUserId, int64(uid))
72 57
 			} else {
73
-				ctx.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"msg": "auth failed, mapClaims[ctxRequestTokenExpired].(float64) error"})
58
+				ctx.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"msg": "auth failed, mapClaims[CtxRequestHeaderUserId].(float64) error"})
74 59
 				return
75 60
 			}
76 61
 		} else {