This commit is contained in:
parent
8b81c41bd7
commit
99acf1fd18
|
@ -234,7 +234,6 @@ linters:
|
||||||
- wrapcheck
|
- wrapcheck
|
||||||
- nonamedreturns
|
- nonamedreturns
|
||||||
- gomnd
|
- gomnd
|
||||||
- gosmopolitan
|
|
||||||
- depguard
|
- depguard
|
||||||
|
|
||||||
enable-all: true
|
enable-all: true
|
||||||
|
|
|
@ -38,11 +38,11 @@ type Administrator struct {
|
||||||
PasswordHash string `json:"password_hash"`
|
PasswordHash string `json:"password_hash"`
|
||||||
}
|
}
|
||||||
type Dashboard struct {
|
type Dashboard struct {
|
||||||
|
MOTD *MessageCard `json:"motd"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Theme string `json:"theme"`
|
Theme string `json:"theme"`
|
||||||
FooterLinks []Link `json:"footer_links"`
|
FooterLinks []Link `json:"footer_links"`
|
||||||
HeaderLinks []Link `json:"header_links"`
|
HeaderLinks []Link `json:"header_links"`
|
||||||
MOTD *MessageCard `json:"motd"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type MessageCard struct {
|
type MessageCard struct {
|
||||||
|
|
|
@ -47,6 +47,7 @@ func (config *Config) AdminEndpoint(c *fiber.Ctx) error {
|
||||||
if config.IsAuthorized(c) { // here the user is submitting the form to change configuration
|
if config.IsAuthorized(c) { // here the user is submitting the form to change configuration
|
||||||
err := config.saveAdminForm(c)
|
err := config.saveAdminForm(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// #nosec the input is admin-defined, and the admin is assumed to be trusted.
|
||||||
return config.RenderAdminPanel(c, &MessageCard{
|
return config.RenderAdminPanel(c, &MessageCard{
|
||||||
Title: "An error occurred!",
|
Title: "An error occurred!",
|
||||||
Content: template.HTML(html.EscapeString(err.Error())),
|
Content: template.HTML(html.EscapeString(err.Error())),
|
||||||
|
@ -122,6 +123,7 @@ func (config *Config) saveAdminForm(c *fiber.Ctx) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.FormValue("motd_title") != "" || c.FormValue("motd_content") != "" {
|
if c.FormValue("motd_title") != "" || c.FormValue("motd_content") != "" {
|
||||||
|
// #nosec the input is admin-defined, and the admin is assumed to be trusted.
|
||||||
form.Dashboard.MOTD = &MessageCard{
|
form.Dashboard.MOTD = &MessageCard{
|
||||||
Title: c.FormValue("motd_title"),
|
Title: c.FormValue("motd_title"),
|
||||||
Content: template.HTML(c.FormValue("motd_content")),
|
Content: template.HTML(c.FormValue("motd_content")),
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
"git.massivebox.net/ecodash/ecodash/src/ecodash"
|
"git.massivebox.net/ecodash/ecodash/src/ecodash"
|
||||||
"git.massivebox.net/ecodash/ecodash/src/tools"
|
"git.massivebox.net/ecodash/ecodash/src/tools"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/gofiber/template/html"
|
"github.com/gofiber/template/html"
|
||||||
"github.com/robfig/cron/v3"
|
"github.com/robfig/cron/v3"
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
Loading…
Reference in a new issue