fix: watchlist updated_at and unified auth middleware

This commit is contained in:
2026-05-02 17:53:08 +02:00
committed by Mikkel Elvers
parent 5940d7828a
commit e5c32fd154
5 changed files with 20 additions and 21 deletions

View File

@@ -3,9 +3,6 @@ package middleware
import (
"net/http"
"strings"
"mal/internal/context"
"mal/internal/db"
)
type AccessPolicy struct {
@@ -47,7 +44,8 @@ func RequireGlobalAuthWithPolicy(policy AccessPolicy) func(http.Handler) http.Ha
return
}
user, ok := r.Context().Value(context.UserKey).(*database.User)
user := GetUser(r.Context())
ok := user != nil
if !ok || user == nil {
if strings.HasPrefix(r.URL.Path, "/api/") || r.Header.Get("HX-Request") == "true" {
w.Header().Set("HX-Redirect", "/login")