1. 修复密码被重复加密的问题

2. gin改为debug模式
This commit is contained in:
2025-09-08 17:07:32 +08:00
parent ca3cf02396
commit 0b16d7d886
3 changed files with 4 additions and 11 deletions

View File

@@ -65,16 +65,8 @@ func (c *Controller) Register(ctx *gin.Context) {
return
}
// 对密码进行哈希处理
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(req.Password), bcrypt.DefaultCost)
if err != nil {
c.logger.Error("密码哈希处理失败: " + err.Error())
controller.SendErrorResponse(ctx, controller.InternalServerErrorCode, "用户注册失败")
return
}
// 创建用户
user, err := c.userRepo.CreateUser(req.Username, string(hashedPassword))
user, err := c.userRepo.CreateUser(req.Username, req.Password)
if err != nil {
c.logger.Error("创建用户失败: " + err.Error())
controller.SendErrorResponse(ctx, controller.InternalServerErrorCode, "用户注册失败")