1. 修复密码被重复加密的问题
2. gin改为debug模式
This commit is contained in:
@@ -63,7 +63,7 @@ type API struct {
|
|||||||
// 初始化Gin引擎和相关配置
|
// 初始化Gin引擎和相关配置
|
||||||
func NewAPI(cfg *config.Config, userRepo repository.UserRepo, operationHistoryRepo repository.OperationHistoryRepo, deviceControlRepo repository.DeviceControlRepo, deviceRepo repository.DeviceRepo, websocketService *service.WebSocketService) *API {
|
func NewAPI(cfg *config.Config, userRepo repository.UserRepo, operationHistoryRepo repository.OperationHistoryRepo, deviceControlRepo repository.DeviceControlRepo, deviceRepo repository.DeviceRepo, websocketService *service.WebSocketService) *API {
|
||||||
// 设置Gin为发布模式
|
// 设置Gin为发布模式
|
||||||
gin.SetMode(gin.ReleaseMode)
|
gin.SetMode(gin.DebugMode)
|
||||||
|
|
||||||
// 创建Gin引擎实例
|
// 创建Gin引擎实例
|
||||||
engine := gin.New()
|
engine := gin.New()
|
||||||
|
|||||||
@@ -65,16 +65,8 @@ func (c *Controller) Register(ctx *gin.Context) {
|
|||||||
return
|
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 {
|
if err != nil {
|
||||||
c.logger.Error("创建用户失败: " + err.Error())
|
c.logger.Error("创建用户失败: " + err.Error())
|
||||||
controller.SendErrorResponse(ctx, controller.InternalServerErrorCode, "用户注册失败")
|
controller.SendErrorResponse(ctx, controller.InternalServerErrorCode, "用户注册失败")
|
||||||
|
|||||||
@@ -24,5 +24,6 @@ type Storage interface {
|
|||||||
// 根据配置返回相应的存储实现
|
// 根据配置返回相应的存储实现
|
||||||
func NewStorage(connectionString string, maxOpenConns, maxIdleConns, connMaxLifetime int) Storage {
|
func NewStorage(connectionString string, maxOpenConns, maxIdleConns, connMaxLifetime int) Storage {
|
||||||
// 当前默认返回PostgreSQL存储实现
|
// 当前默认返回PostgreSQL存储实现
|
||||||
return NewPostgresStorage(connectionString, maxOpenConns, maxIdleConns, connMaxLifetime)
|
s := NewPostgresStorage(connectionString, maxOpenConns, maxIdleConns, connMaxLifetime)
|
||||||
|
return s
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user