mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-09-17 16:56:38 +08:00
always parse authorization token for all request
This commit is contained in:
parent
0cbc284e42
commit
264e77f383
@ -165,21 +165,21 @@ func authorizeMiddleware(s *AppServer, client *redis.Client) gin.HandlerFunc {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil && needLogin(c) {
|
||||||
resp.NotAuth(c, fmt.Sprintf("Error with parse auth token: %v", err))
|
resp.NotAuth(c, fmt.Sprintf("Error with parse auth token: %v", err))
|
||||||
c.Abort()
|
c.Abort()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
claims, ok := token.Claims.(jwt.MapClaims)
|
claims, ok := token.Claims.(jwt.MapClaims)
|
||||||
if !ok || !token.Valid {
|
if !ok || !token.Valid && needLogin(c) {
|
||||||
resp.NotAuth(c, "Token is invalid")
|
resp.NotAuth(c, "Token is invalid")
|
||||||
c.Abort()
|
c.Abort()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
expr := utils.IntValue(utils.InterfaceToString(claims["expired"]), 0)
|
expr := utils.IntValue(utils.InterfaceToString(claims["expired"]), 0)
|
||||||
if expr > 0 && int64(expr) < time.Now().Unix() {
|
if expr > 0 && int64(expr) < time.Now().Unix() && needLogin(c) {
|
||||||
resp.NotAuth(c, "Token is expired")
|
resp.NotAuth(c, "Token is expired")
|
||||||
c.Abort()
|
c.Abort()
|
||||||
return
|
return
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
VUE_APP_API_HOST=http://172.22.11.200:5678
|
VUE_APP_API_HOST=http://localhost:5678
|
||||||
VUE_APP_WS_HOST=ws://172.22.11.200:5678
|
VUE_APP_WS_HOST=ws://localhost:5678
|
||||||
VUE_APP_USER=18575670125
|
VUE_APP_USER=18575670125
|
||||||
VUE_APP_PASS=12345678
|
VUE_APP_PASS=12345678
|
||||||
VUE_APP_ADMIN_USER=admin
|
VUE_APP_ADMIN_USER=admin
|
||||||
|
Loading…
Reference in New Issue
Block a user