mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-08-14 07:10:58 +00:00
fix(update): read setUpdateChannel body as form field, not JSON
The panel's axios layer posts application/x-www-form-urlencoded, so the dev-channel toggle sent dev=true and ShouldBindJSON failed with 'invalid character d'. Parse c.PostForm("dev") to match the codebase's form-encoded POST convention.
This commit is contained in:
@@ -4253,9 +4253,6 @@
|
|||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
|
||||||
"example": {
|
|
||||||
"dev": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -404,7 +404,10 @@ export const sections: readonly Section[] = [
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
path: '/panel/api/server/setUpdateChannel',
|
path: '/panel/api/server/setUpdateChannel',
|
||||||
summary: 'Toggle the panel update channel between stable and the rolling per-commit dev release. Only effective on dev builds.',
|
summary: 'Toggle the panel update channel between stable and the rolling per-commit dev release. Only effective on dev builds.',
|
||||||
body: '{\n "dev": true\n}',
|
params: [
|
||||||
|
{ name: 'dev', in: 'body (form)', type: 'boolean', desc: 'true = dev channel, false = stable.' },
|
||||||
|
],
|
||||||
|
body: 'dev=true',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|||||||
@@ -214,14 +214,12 @@ func (a *ServerController) updatePanel(c *gin.Context) {
|
|||||||
|
|
||||||
// setUpdateChannel toggles whether self-update tracks the rolling dev release.
|
// setUpdateChannel toggles whether self-update tracks the rolling dev release.
|
||||||
func (a *ServerController) setUpdateChannel(c *gin.Context) {
|
func (a *ServerController) setUpdateChannel(c *gin.Context) {
|
||||||
var req struct {
|
dev, err := strconv.ParseBool(c.PostForm("dev"))
|
||||||
Dev bool `json:"dev"`
|
if err != nil {
|
||||||
}
|
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
|
||||||
jsonMsg(c, "invalid data", err)
|
jsonMsg(c, "invalid data", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := a.settingService.SetDevChannelEnable(req.Dev)
|
err = a.settingService.SetDevChannelEnable(dev)
|
||||||
jsonMsg(c, I18nWeb(c, "pages.index.updateChannelChanged"), err)
|
jsonMsg(c, I18nWeb(c, "pages.index.updateChannelChanged"), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user