mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-08 16:46: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"
|
||||
)
|
||||
|
||||
@@ -13,18 +13,12 @@ func RelayAuth() 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
|
||||
}
|
||||
if node.NodeType != "tunnel_relay" {
|
||||
c.JSON(http.StatusForbidden, gin.H{
|
||||
"success": false,
|
||||
"message": "此节点不是 TunnelRelay 类型",
|
||||
})
|
||||
response.RespondForbidden(c, "此节点不是 TunnelRelay 类型")
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user