mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-07 08:06:37 +08:00
[优化] response 结构调整
This commit is contained in:
@@ -2,7 +2,7 @@ package middleware
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"openflare/common/response"
|
||||
"openflare/service"
|
||||
)
|
||||
|
||||
@@ -11,10 +11,7 @@ func AgentAuth() func(c *gin.Context) {
|
||||
token := c.GetHeader("X-Agent-Token")
|
||||
node, err := service.AuthenticateAccessToken(token)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusUnauthorized, gin.H{
|
||||
"success": false,
|
||||
"message": "无权进行此操作,Agent Token 无效",
|
||||
})
|
||||
response.RespondUnauthorized(c, "无权进行此操作,Agent Token 无效")
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
@@ -32,10 +29,7 @@ func AgentRegisterAuth() func(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
if err := service.ValidateDiscoveryToken(token); err != nil {
|
||||
c.JSON(http.StatusUnauthorized, gin.H{
|
||||
"success": false,
|
||||
"message": "无权进行此操作,注册 Token 无效",
|
||||
})
|
||||
response.RespondUnauthorized(c, "无权进行此操作,注册 Token 无效")
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user