diff --git a/internal/util/admins.go b/internal/util/admins.go index 93aff83..d09fdf6 100644 --- a/internal/util/admins.go +++ b/internal/util/admins.go @@ -16,10 +16,6 @@ var ( ) func IsAdminSessionValid(token string) bool { - if DevMode { - return true - } - AdminMutex.RLock() session, exists := AdminSessions[token] AdminMutex.RUnlock() diff --git a/internal/util/util.go b/internal/util/util.go index 971147c..03b943b 100644 --- a/internal/util/util.go +++ b/internal/util/util.go @@ -10,7 +10,7 @@ import ( "strings" ) -const DevMode = false +const DevMode = true func FormatBytes(bytes int64) string { const ( diff --git a/web/main.go b/web/main.go index d2f9709..60ea8f7 100644 --- a/web/main.go +++ b/web/main.go @@ -25,7 +25,7 @@ import ( func AdminOnlyMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { c, err := r.Cookie("comfy_admin") - if err != nil || !util.IsAdminSessionValid(c.Value) { + if !util.DevMode && (err != nil || !util.IsAdminSessionValid(c.Value)) { // Check if it's an HTMX request if r.Header.Get("HX-Request") == "true" { w.Header().Set("HX-Redirect", "/authorize") @@ -496,16 +496,6 @@ func main() { }) - r.Get("/authorized", func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "text/plain; charset=utf-8") - - if c, err := r.Cookie("comfy_admin"); err == nil && util.IsAdminSessionValid(c.Value) { - w.Write([]byte("true")) - } else { - w.Write([]byte("false")) - } - }) - r.Route("/admin", func(r chi.Router) { r.Use(AdminOnlyMiddleware) diff --git a/web/static/index.js b/web/static/index.js index c2c0fa2..01628af 100644 --- a/web/static/index.js +++ b/web/static/index.js @@ -108,3 +108,7 @@ function applyCatalogSearch() { function currentBoardSlug() { return window.location.pathname.split("/")[1] || ""; } + +function getCurrentDateISOString() { + return (new Date()).toISOString().slice(0, 16) +} diff --git a/web/views/thread.templ b/web/views/thread.templ index 1627aaf..4927a60 100644 --- a/web/views/thread.templ +++ b/web/views/thread.templ @@ -48,7 +48,11 @@ templ PostAdminDialog(post database.Post) {
Days: - +