🎨 Support for modifying Settings - About - API token https://github.com/siyuan-note/siyuan/issues/9448

This commit is contained in:
Daniel 2023-10-22 10:31:06 +08:00
parent df3cae411f
commit c597bd2f3d
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 15 additions and 0 deletions

View file

@ -37,6 +37,7 @@ func ServeAPI(ginServer *gin.Engine) {
// 需要鉴权
ginServer.Handle("POST", "/api/system/getEmojiConf", model.CheckAuth, getEmojiConf)
ginServer.Handle("POST", "/api/system/setAPIToken", model.CheckAuth, model.CheckReadonly, setAPIToken)
ginServer.Handle("POST", "/api/system/setAccessAuthCode", model.CheckAuth, model.CheckReadonly, setAccessAuthCode)
ginServer.Handle("POST", "/api/system/setFollowSystemLockScreen", model.CheckAuth, model.CheckReadonly, setFollowSystemLockScreen)
ginServer.Handle("POST", "/api/system/setNetworkServe", model.CheckAuth, model.CheckReadonly, setNetworkServe)

View file

@ -239,6 +239,20 @@ func setUILayout(c *gin.Context) {
model.Conf.Save()
}
func setAPIToken(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
token := arg["token"].(string)
model.Conf.Api.Token = token
model.Conf.Save()
}
func setAccessAuthCode(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)