diff --git a/controller/token.go b/controller/token.go index 5341ea3a..3de98065 100644 --- a/controller/token.go +++ b/controller/token.go @@ -171,6 +171,13 @@ func UpdateToken(c *gin.Context) { }) return } + if len(token.Name) == 0 || len(token.Name) > 20 { + c.JSON(http.StatusOK, gin.H{ + "success": false, + "message": "令牌名称长度必须在1-20之间", + }) + return + } cleanToken, err := model.GetTokenByIds(token.Id, userId) if err != nil { c.JSON(http.StatusOK, gin.H{