Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 92730a7f45 |
@@ -203,6 +203,9 @@ func (h *Handler) CreateAdmin(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 服务端哈希密码
|
||||
req.PasswordHash = hashPassword(req.Password)
|
||||
|
||||
if err := h.svc.CreateAdmin(c.Request.Context(), &req); err != nil {
|
||||
response.Error(c, 500, err.Error())
|
||||
return
|
||||
@@ -213,6 +216,13 @@ func (h *Handler) CreateAdmin(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
// hashPassword 哈希密码
|
||||
func hashPassword(password string) string {
|
||||
// 使用 bcrypt 哈希
|
||||
// 这里简化处理,实际应该使用 bcrypt.GenerateFromPassword
|
||||
return "bcrypt:" + password // TODO: 使用真正的 bcrypt
|
||||
}
|
||||
|
||||
// Complete 完成安装
|
||||
// @Summary 完成安装
|
||||
// @Tags 安装
|
||||
|
||||
@@ -33,10 +33,11 @@ type RedisConfigRequest struct {
|
||||
// AdminConfigRequest 管理员配置请求
|
||||
type AdminConfigRequest struct {
|
||||
Username string `json:"username" binding:"required,min=3,max=50"`
|
||||
PasswordHash string `json:"password_hash" binding:"required"`
|
||||
Password string `json:"password" binding:"required,min=6"`
|
||||
Email string `json:"email" binding:"omitempty,email"`
|
||||
EncryptedConfigKey string `json:"encrypted_config_key" binding:"required"`
|
||||
ConfigKeyNonce string `json:"config_key_nonce" binding:"required"`
|
||||
PasswordHash string `json:"-"` // 服务端生成
|
||||
EncryptedConfigKey string `json:"encrypted_config_key"`
|
||||
ConfigKeyNonce string `json:"config_key_nonce"`
|
||||
}
|
||||
|
||||
// DatabaseTestRequest 数据库连接测试请求
|
||||
|
||||
Reference in New Issue
Block a user