瀏覽代碼

more simple api

Paul 6 年之前
父節點
當前提交
c828f7303f
共有 2 個文件被更改,包括 3 次插入3 次删除
  1. 1
    1
      middleware/auth/auth.go
  2. 2
    2
      middleware/auth/session_redis.go

+ 1
- 1
middleware/auth/auth.go 查看文件

@@ -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 查看文件

@@ -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 {