|
@@ -53,7 +53,15 @@ func Auth(authKey string) gin.HandlerFunc {
|
53
|
53
|
|
54
|
54
|
if mapClaims, ok := token.Claims.(jwt.MapClaims); ok {
|
55
|
55
|
if expired, ok := mapClaims[ctxRequestTokenExpired].(float64); ok {
|
56
|
|
- if int64(expired) < time.Now().Unix() {
|
|
56
|
+ if expired == 0 {
|
|
57
|
+ // Only cookie is exists, check token expired. app expired by itself call logout when app exit
|
|
58
|
+ if _, err := ctx.Cookie(ctxRequestCookieAuthorization); err != nil {
|
|
59
|
+ ctx.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"msg": "auth failed, token timeout"})
|
|
60
|
+ return
|
|
61
|
+ }
|
|
62
|
+ }
|
|
63
|
+
|
|
64
|
+ if expired < 0 || (int64(expired) < time.Now().Unix()) {
|
57
|
65
|
ctx.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"msg": "auth failed, token timeout"})
|
58
|
66
|
return
|
59
|
67
|
}
|