From 16f397d507f296edf46afbc893f681b6a984c987 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Sun, 21 Jul 2024 11:12:54 +0800 Subject: [PATCH] =?UTF-8?q?cid=E6=B7=BB=E5=8A=A0run=E6=9D=83=E9=99=90?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/cid.go | 18 ++++++++++++++++-- proto/status.go | 4 +++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/handler/cid.go b/handler/cid.go index 2108c95..7c3ac65 100644 --- a/handler/cid.go +++ b/handler/cid.go @@ -50,10 +50,17 @@ func SetUpCIDGroup(router *gin.Engine) { } func RunCID(c *gin.Context) { var req CIDRunReq + id, _ := c.Get("id") + authID := int(id.(float64)) + //获取权限 + user := dao.FindUserByUserID(authID) + if user.Run == false { + c.JSON(200, gin.H{"error": "no run Permissions", "code": proto.NoRunPermissions, "message": "no run Permissions"}) + return + } + if err := c.ShouldBind(&req); err == nil { // 获取用户ID - id, _ := c.Get("id") - authID := int(id.(float64)) username, _ := c.Get("username") cid := dao.FindCIDByID(req.ID, authID) if cid.ID == 0 { @@ -165,11 +172,18 @@ func CIDCallback(c *gin.Context) { fmt.Println("token:", token, "cid_id:", cid_id) //将cid转换为int cid, _ := strconv.Atoi(cid_id) + if token == "" || cid == 0 { c.JSON(200, gin.H{"error": "parameter error", "code": proto.ParameterError, "message": "failed"}) return } res := dao.FindCIDByIDAndToken(cid, token) + + user := dao.FindUserByUserID(res.Auth_id) + if user.Run == false { + c.JSON(200, gin.H{"error": "no run Permissions", "code": proto.NoRunPermissions, "message": "the user has no run Permissions"}) + return + } if res.ID != 0 { user := dao.FindUserByID(res.Auth_id) go RunShell(user[0].Name, res.Url, res.Script, int(res.ID), res.Auth_id) diff --git a/proto/status.go b/proto/status.go index cc636b1..42268d1 100644 --- a/proto/status.go +++ b/proto/status.go @@ -43,5 +43,7 @@ const ( UUIDNotFound = 18 // uuid不存在 //Tool - NoRedisPermissions = 51 + NoRedisPermissions = 51 + NoRunPermissions = 52 + NoDevicePermissions = 53 )