From e4265f5ddc92f13ddd20315045ea05e769693475 Mon Sep 17 00:00:00 2001 From: zhangchenhao Date: Fri, 9 May 2025 10:35:21 +0800 Subject: [PATCH] =?UTF-8?q?api=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/middleware/auth.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/middleware/auth.go b/backend/middleware/auth.go index c7a49d9..a3257f7 100644 --- a/backend/middleware/auth.go +++ b/backend/middleware/auth.go @@ -134,6 +134,10 @@ func checkApiKey(c *gin.Context) bool { return false } apiKey := public.GetSettingIgnoreError("api_key") + if apiKey == "" { + c.JSON(http.StatusBadRequest, gin.H{"error": "未开启api"}) + return false + } // timestamp := time.Now().Unix() ApiToken := generateSignature(form.Timestamp, apiKey) if form.ApiToken != ApiToken {