Files
metabuilder/packages/ui_permissions/seed/scripts/check.lua
T
git fac6a49a64 Refactor and enhance permission handling, UI components, and package metadata
- Updated ModelTable component to use more specific types for records and edit actions.
- Enhanced NavItem component to extend MUI ListItemProps for better type safety.
- Refactored normalizeLuaStructure to improve type handling with JsonValue.
- Updated LuaUIComponent and related types to use JsonValue for props and handler arguments.
- Modified AuditLog interface to use JsonObject for metadata.
- Improved importUIPages function to use a more specific database interface.
- Refactored builder-types to use JsonValue for component props and default values.
- Updated package index.json to reflect changes in package descriptions, dependencies, and added minLevel attributes.
- Enhanced permissions in Lua scripts to include new roles (moderator, supergod).
- Renamed and updated metadata for UI level packages to reflect new roles and functionalities.
- Added new UI level package (Level 6 - Supergod Panel) with associated scripts and components.
- Updated permissions check script to include new moderator role checks.
2025-12-30 00:20:29 +00:00

32 lines
622 B
Lua

local LEVELS = require("levels")
local M = {}
local ROLE_MAP = {
public = LEVELS.PUBLIC,
user = LEVELS.USER,
moderator = LEVELS.MODERATOR,
admin = LEVELS.ADMIN,
god = LEVELS.GOD,
supergod = LEVELS.SUPERGOD
}
function M.get_level(user)
if not user then return LEVELS.PUBLIC end
return ROLE_MAP[user.role] or LEVELS.PUBLIC
end
function M.can_access(user, required_level)
return M.get_level(user) >= required_level
end
function M.is_moderator_or_above(user)
return M.get_level(user) >= LEVELS.MODERATOR
end
function M.is_admin_or_above(user)
return M.get_level(user) >= LEVELS.ADMIN
end
return M