Browse Source

more simple api

Paul 6 years ago
parent
commit
c828f7303f
2 changed files with 3 additions and 3 deletions
  1. 1
    1
      middleware/auth/auth.go
  2. 2
    2
      middleware/auth/session_redis.go

+ 1
- 1
middleware/auth/auth.go View File

@@ -46,7 +46,7 @@ func Auth(authKey string, session Session) gin.HandlerFunc {
46 46
 			return
47 47
 		}
48 48
 
49
-		if !session.IsExistsJwtToken(token.Signature) {
49
+		if !session.IsExistsJwtToken(token.Raw) {
50 50
 			ctx.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"msg": "auth failed, token expired by server"})
51 51
 			return
52 52
 		}

+ 2
- 2
middleware/auth/session_redis.go View File

@@ -22,8 +22,8 @@ func NewRedisSessionStore(address string, password string) *RedisSessionStore {
22 22
 	return session
23 23
 }
24 24
 
25
-func (rss *RedisSessionStore) StoreJwtToken(key string, value string, timeout time.Duration) error {
26
-	return rss.client.Set(key, value, timeout).Err()
25
+func (rss *RedisSessionStore) StoreJwtToken(key string, value string, timeout int64) error {
26
+	return rss.client.Set(key, value, time.Duration(timeout) * time.Second).Err()
27 27
 }
28 28
 
29 29
 func (rss *RedisSessionStore) IsExistsJwtToken(key string) bool {