mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-04 02:32:57 +00:00
hot fix #1
This commit is contained in:
@@ -157,7 +157,13 @@ func RoleAuth(requiredRole string) gin.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
// Check if user has the required role
|
||||
// Editors are allowed to access routes that require either "editor" or "admin"
|
||||
if userRole == "editor" && (requiredRole == "editor" || requiredRole == "admin") {
|
||||
c.Next()
|
||||
return
|
||||
}
|
||||
|
||||
// Check if user has the required role exactly
|
||||
if userRole != requiredRole {
|
||||
c.JSON(http.StatusForbidden, gin.H{"error": "Insufficient permissions"})
|
||||
c.Abort()
|
||||
|
||||
Reference in New Issue
Block a user