fix(pve): Password字段JSON tag为-导致前端密码无法传入
- models.go: PVEHost.Password json tag "-" -> "password",
否则c.ShouldBindJSON无法绑定前端传的password字段
- handlers/pve.go: 返回前清空Password字段防止泄露
[金渐层/K2.6-code-preview🐾]
This commit is contained in:
@@ -67,6 +67,7 @@ func (h *PVEHandler) Get(c *gin.Context) {
|
||||
}
|
||||
|
||||
host.PasswordEnc = ""
|
||||
host.Password = ""
|
||||
c.JSON(http.StatusOK, host)
|
||||
}
|
||||
|
||||
@@ -98,6 +99,7 @@ func (h *PVEHandler) Create(c *gin.Context) {
|
||||
}
|
||||
|
||||
host.PasswordEnc = ""
|
||||
host.Password = ""
|
||||
c.JSON(http.StatusCreated, host)
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ type PVEHost struct {
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
// 运行时使用,不存储
|
||||
Password string `json:"-"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
type PVEVMStatus struct {
|
||||
|
||||
Reference in New Issue
Block a user