Feature user and admin panels (#30)

This commit is contained in:
2026-02-16 20:30:36 +00:00
parent c5866ae785
commit 2fc4f6980c
15 changed files with 1805 additions and 111 deletions

View File

@@ -0,0 +1,22 @@
package middleware
import (
"net/http"
"github.com/gin-gonic/gin"
)
// RequireAdmin returns middleware that restricts access to admin users.
// Must be used after Auth() middleware which sets "role" in context.
func RequireAdmin() gin.HandlerFunc {
return func(c *gin.Context) {
role, exists := c.Get("role")
if !exists || role != "admin" {
c.AbortWithStatusJSON(http.StatusForbidden, gin.H{
"error": "admin access required",
})
return
}
c.Next()
}
}