fix: resolve context key cycle for admin check

This commit is contained in:
2026-04-22 21:23:38 +02:00
parent 77f0daca26
commit ee05ad7511
8 changed files with 23 additions and 36 deletions

View File

@@ -11,6 +11,7 @@ import (
"mal/api/auth"
"mal/internal/db"
"mal/internal/middleware"
webcontext "mal/web/context"
"mal/web/templates"
)
@@ -166,7 +167,7 @@ func GetImpersonatedUserID(r *http.Request) string {
}
// Verify the current user is admin
user, ok := r.Context().Value(middleware.UserContextKey).(*database.User)
user, ok := r.Context().Value(webcontext.UserKey).(*database.User)
if !ok || user == nil || !middleware.IsAdmin(user) {
return ""
}