tooltips + verwaltung finish

This commit is contained in:
Simon Martens
2025-05-27 15:08:55 +02:00
parent 2ad431ca09
commit 4e13a0b5cb
28 changed files with 339 additions and 213 deletions

View File

@@ -0,0 +1,23 @@
package middleware
import (
"github.com/Theodor-Springmann-Stiftung/musenalm/templating"
"github.com/pocketbase/pocketbase/core"
)
// INFO: Here the URL must have a path value "uid" which is the user ID of the affected user.
func IsAdminOrEditor() func(*core.RequestEvent) error {
return func(e *core.RequestEvent) error {
req := templating.NewRequest(e)
user := req.User()
if user == nil {
return e.Error(401, "Unauthorized", nil)
}
if user.Role != "Editor" && user.Role != "Admin" {
return e.Error(403, "Forbidden", nil)
}
return e.Next()
}
}