🎨 加入只读模式配置

This commit is contained in:
Liang Ding 2022-08-09 10:09:38 +08:00
parent 58611c8f1e
commit 24d4654030
No known key found for this signature in database
GPG Key ID: 136F30F901A2231D
2 changed files with 12 additions and 0 deletions

View File

@ -32,6 +32,12 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
result := gulu.Ret.NewResult()
defer gulu.Ret.RetResult(w, r, result)
if conf.Wide.ReadOnly {
result.Code = -1
result.Msg = "readonly mode"
return
}
httpSession, _ := session.HTTPSession.Get(r, session.CookieName)
if httpSession.IsNew {
http.Error(w, "Forbidden", http.StatusForbidden)

View File

@ -34,6 +34,12 @@ func SaveHandler(w http.ResponseWriter, r *http.Request) {
result := gulu.Ret.NewResult()
defer gulu.Ret.RetResult(w, r, result)
if conf.Wide.ReadOnly {
result.Code = -1
result.Msg = "readonly mode"
return
}
session, _ := session.HTTPSession.Get(r, session.CookieName)
if session.IsNew {
http.Error(w, "Forbidden", http.StatusForbidden)