From 4fa123baa816477633ad953045953ca00628321f Mon Sep 17 00:00:00 2001 From: coward Date: Thu, 22 Aug 2024 14:16:33 +0800 Subject: [PATCH] =?UTF-8?q?:art:=E4=BC=98=E5=8C=96=E4=B8=80=E4=B8=8B?= =?UTF-8?q?=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- http/api/dashboard.go | 5 +++++ http/middleware/authorization.go | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/http/api/dashboard.go b/http/api/dashboard.go index f59f10e..dc43880 100644 --- a/http/api/dashboard.go +++ b/http/api/dashboard.go @@ -3,6 +3,7 @@ package api import ( "fmt" "github.com/gin-gonic/gin" + "strings" "time" "wireguard-ui/component" "wireguard-ui/http/param" @@ -77,6 +78,10 @@ func (DashboardApi) ConnectionList(c *gin.Context) { for _, iaip := range peer.AllowedIPs { ipAllocation += iaip.String() + "," } + // 去除一下最右边的逗号 + if len(ipAllocation) > 0 { + ipAllocation = strings.TrimRight(ipAllocation, ",") + } connections = append(connections, vo.DataTraffic{ Name: clientInfo.Name, Email: clientInfo.Email, diff --git a/http/middleware/authorization.go b/http/middleware/authorization.go index 0af4f0b..dc225c6 100644 --- a/http/middleware/authorization.go +++ b/http/middleware/authorization.go @@ -50,13 +50,13 @@ func Authorization() gin.HandlerFunc { // 查询用户 user, err := service.User().GetUserById(userClaims.ID) if err != nil { - response.R(c).FailedWithError("用户不存在") + response.R(c).AuthorizationFailed("用户不存在") c.Abort() return } if user.Status != constant.Enabled { - response.R(c).FailedWithError("用户状态异常,请联系管理员处理!") + response.R(c).AuthorizationFailed("用户状态异常,请联系管理员处理!") c.Abort() return }