Start integrating Hugo in the new plugin
Former-commit-id: dcc6bd82b3d3a89637a1032aad1a25d0b1f80046 [formerly 8784cd37bf58e81cdbe1bcec00e6f16b58efc915] [formerly 9e25850e063ae0825de337d5d5f29cee601b9040 [formerly 8b1d36dfb9ebfa001ddeef98034bb5a73d135c94]] Former-commit-id: 04a38bea2d141093570d9289d0d0a056a136fe8a [formerly 5995538504889e698aa6cd35b7da40c38b5d5ddf] Former-commit-id: 8c81a0b060167e1a2983a99bc87b380838ac07dc
This commit is contained in:
16
settings.go
16
settings.go
@@ -6,7 +6,7 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func commandsHandler(c *requestContext, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func commandsHandler(c *RequestContext, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
switch r.Method {
|
||||
case http.MethodGet:
|
||||
return commandsGetHandler(c, w, r)
|
||||
@@ -17,16 +17,16 @@ func commandsHandler(c *requestContext, w http.ResponseWriter, r *http.Request)
|
||||
return http.StatusMethodNotAllowed, nil
|
||||
}
|
||||
|
||||
func commandsGetHandler(c *requestContext, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
if !c.us.Admin {
|
||||
func commandsGetHandler(c *RequestContext, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
if !c.User.Admin {
|
||||
return http.StatusForbidden, nil
|
||||
}
|
||||
|
||||
return renderJSON(w, c.fm.Commands)
|
||||
return renderJSON(w, c.FM.Commands)
|
||||
}
|
||||
|
||||
func commandsPutHandler(c *requestContext, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
if !c.us.Admin {
|
||||
func commandsPutHandler(c *RequestContext, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
if !c.User.Admin {
|
||||
return http.StatusForbidden, nil
|
||||
}
|
||||
|
||||
@@ -42,10 +42,10 @@ func commandsPutHandler(c *requestContext, w http.ResponseWriter, r *http.Reques
|
||||
return http.StatusBadRequest, errors.New("Invalid JSON")
|
||||
}
|
||||
|
||||
if err := c.fm.db.Set("config", "commands", commands); err != nil {
|
||||
if err := c.FM.db.Set("config", "commands", commands); err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
c.fm.Commands = commands
|
||||
c.FM.Commands = commands
|
||||
return http.StatusOK, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user