bug fixes, half-finished admin ui, and a more

This commit is contained in:
Zoe
2024-09-23 01:21:28 -05:00
parent 6e6bc1c45b
commit 66f8437351
35 changed files with 1039 additions and 141 deletions

22
middleware/admin.go Normal file
View File

@@ -0,0 +1,22 @@
package middleware
import (
"filething/models"
"net/http"
"github.com/labstack/echo/v4"
)
func AdminMiddleware() echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
user := c.Get("user").(*models.User)
if !user.Admin {
return echo.NewHTTPError(http.StatusForbidden, "You are not an administrator")
}
return next(c)
}
}
}