feat: gateway store.

This commit is contained in:
2026-05-01 20:29:53 +08:00
parent 942b0eeae1
commit cd490eea36
6 changed files with 105 additions and 1 deletions
+25
View File
@@ -7,6 +7,31 @@ import (
"github.com/gin-gonic/gin"
)
func RequireOperatorOrHigher() gin.HandlerFunc {
return func(c *gin.Context) {
roleValue, exists := c.Get("role")
if !exists {
c.JSON(http.StatusForbidden, gin.H{"error": "missing user role"})
c.Abort()
return
}
role, ok := roleValue.(models.UserRole)
if !ok {
c.JSON(http.StatusForbidden, gin.H{"error": "invalid user role"})
c.Abort()
return
}
if role != models.UserRoleOperator &&
role != models.UserRoleRegionAdmin &&
role != models.UserRoleSuperAdmin {
c.JSON(http.StatusForbidden, gin.H{"error": "insufficient role permissions"})
c.Abort()
return
}
c.Next()
}
}
func RequireStepTrainingAccess() gin.HandlerFunc {
return func(c *gin.Context) {
roleValue, exists := c.Get("role")