mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-05-06 03:29:35 +00:00
26 lines
918 B
Lua
26 lines
918 B
Lua
---@alias UserRole "user" | "moderator" | "admin" | "god" | "supergod"
|
|
|
|
---@class SocialUser
|
|
---@field role? UserRole User role
|
|
|
|
---@class PermissionsModule
|
|
---@field can_post fun(user?: SocialUser): boolean Check if user can post
|
|
---@field can_moderate fun(user?: SocialUser): boolean Check if user can moderate
|
|
local Permissions = {}
|
|
|
|
---Check if user can create posts
|
|
---@param user? SocialUser User to check
|
|
---@return boolean
|
|
function Permissions.can_post(user)
|
|
return user and (user.role == "user" or user.role == "moderator" or user.role == "admin" or user.role == "god" or user.role == "supergod")
|
|
end
|
|
|
|
---Check if user can moderate content
|
|
---@param user? SocialUser User to check
|
|
---@return boolean
|
|
function Permissions.can_moderate(user)
|
|
return user and (user.role == "moderator" or user.role == "admin" or user.role == "god" or user.role == "supergod")
|
|
end
|
|
|
|
return Permissions
|