From 9032b5cfbf2be69d2bdb2f6bf547fc28981165ce Mon Sep 17 00:00:00 2001 From: CalciumIon <1808837298@qq.com> Date: Tue, 17 Sep 2024 23:07:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=9D=E5=A7=8B=E4=BB=A4=E7=89=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/user.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/controller/user.go b/controller/user.go index f33b9de..e69a613 100644 --- a/controller/user.go +++ b/controller/user.go @@ -187,7 +187,7 @@ func Register(c *gin.Context) { }) return } - + // 获取插入后的用户ID var insertedUser model.User if err := model.DB.Where("username = ?", cleanUser.Username).First(&insertedUser).Error; err != nil { @@ -199,23 +199,15 @@ func Register(c *gin.Context) { } // 生成默认令牌 if constant.GenerateDefaultToken { - var insertedUser model.User - if err := model.DB.Where("username = ?", cleanUser.Username).First(&insertedUser).Error; err != nil { - c.JSON(http.StatusOK, gin.H{ - "success": false, - "message": "用户注册失败或用户ID获取失败", - }) - return - } // 生成默认令牌 token := model.Token{ UserId: insertedUser.Id, // 使用插入后的用户ID - Name: cleanUser.Username + "的初始令牌", + Name: cleanUser.Username + "的初始令牌", Key: common.GenerateKey(), CreatedTime: common.GetTimestamp(), AccessedTime: common.GetTimestamp(), - ExpiredTime: -1, // 永不过期 - RemainQuota: 500000, // 示例额度 + ExpiredTime: -1, // 永不过期 + RemainQuota: 500000, // 示例额度 UnlimitedQuota: true, ModelLimitsEnabled: false, }