Compare commits
2 Commits
4e915d02ef
...
3721ba137d
| Author | SHA1 | Date |
|---|---|---|
|
|
3721ba137d | |
|
|
9ef020f229 |
|
|
@ -72,13 +72,13 @@ func RunCID(c *gin.Context) {
|
||||||
|
|
||||||
if err := c.ShouldBind(&req); err == nil {
|
if err := c.ShouldBind(&req); err == nil {
|
||||||
// 获取用户ID
|
// 获取用户ID
|
||||||
username, _ := c.Get("username")
|
//username, _ := c.Get("username")
|
||||||
cid := dao.FindCIDByID(req.ID, authID)
|
cid := dao.FindCIDByID(req.ID, authID)
|
||||||
if cid.ID == 0 {
|
if cid.ID == 0 {
|
||||||
c.JSON(200, gin.H{"error": "CID not found", "code": proto.OperationFailed, "message": "failed"})
|
c.JSON(200, gin.H{"error": "CID not found", "code": proto.OperationFailed, "message": "failed"})
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
go RunShell(username.(string), cid.Url, cid.Script, req.ID, authID)
|
go RunShell("", cid.Url, cid.Script, req.ID, authID)
|
||||||
c.JSON(200, gin.H{"code": proto.SuccessCode, "message": "success", "data": "success"})
|
c.JSON(200, gin.H{"code": proto.SuccessCode, "message": "success", "data": "success"})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
2
main.go
2
main.go
|
|
@ -178,7 +178,9 @@ func JWTAuthMiddleware() gin.HandlerFunc {
|
||||||
|
|
||||||
// 将用户信息添加到上下文中
|
// 将用户信息添加到上下文中
|
||||||
id := token.Claims.(jwt.MapClaims)["id"]
|
id := token.Claims.(jwt.MapClaims)["id"]
|
||||||
|
username := token.Claims.(jwt.MapClaims)["username"]
|
||||||
c.Set("id", id)
|
c.Set("id", id)
|
||||||
|
c.Set("username", username)
|
||||||
c.Set("user_id", int(id.(float64)))
|
c.Set("user_id", int(id.(float64)))
|
||||||
|
|
||||||
if UserFuncIntercept(int(id.(float64)), c.Request.URL.Path) {
|
if UserFuncIntercept(int(id.(float64)), c.Request.URL.Path) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue