|
|
|
|
53
|
|
53
|
|
54
|
if mapClaims, ok := token.Claims.(jwt.MapClaims); ok {
|
54
|
if mapClaims, ok := token.Claims.(jwt.MapClaims); ok {
|
55
|
if expired, ok := mapClaims[ctxRequestTokenExpired].(float64); ok {
|
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
|
ctx.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"msg": "auth failed, token timeout"})
|
65
|
ctx.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"msg": "auth failed, token timeout"})
|
58
|
return
|
66
|
return
|
59
|
}
|
67
|
}
|