You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
634 B
22 lines
634 B
package api
|
|
|
|
import "net/http"
|
|
|
|
func (r *Router) handleClearSystemLogs(w http.ResponseWriter, req *http.Request) {
|
|
ctx, ok := r.authorizeCommand(w, req, commandSpec{Action: "log.system.clear", Target: "system", Permission: "log.clear"})
|
|
if !ok {
|
|
return
|
|
}
|
|
var body struct {
|
|
Confirmation string `json:"confirmation"`
|
|
}
|
|
if ok, _ := decodeJSONBody(w, req, &body, false); !ok {
|
|
return
|
|
}
|
|
if body.Confirmation != "SYSTEM" {
|
|
writeError(w, http.StatusBadRequest, "validation_failed", "confirm SYSTEM exactly; audit records are preserved")
|
|
return
|
|
}
|
|
result, err := r.store.ClearSystemLogs(ctx)
|
|
writeResult(w, result, err)
|
|
}
|
|
|