Initial commit: FlexiCraft Web Portal + Discord SSO + Quartz/Iron engines
This commit is contained in:
commit
f488ff57c5
19 changed files with 3256 additions and 0 deletions
32
core/auth_tiers.py
Normal file
32
core/auth_tiers.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
TIER_LEVELS = {
|
||||
"visitor": 0,
|
||||
"citizen": 1,
|
||||
"moderation": 2,
|
||||
"charcoal": 3,
|
||||
"guardian": 4,
|
||||
"admin": 5
|
||||
}
|
||||
|
||||
def compute_user_tier(role_ids: list, role_tiers_cfg: dict) -> str:
|
||||
rset = {str(r) for r in role_ids}
|
||||
if rset & set(role_tiers_cfg.get("admin", [])):
|
||||
return "admin"
|
||||
if rset & set(role_tiers_cfg.get("guardian", [])):
|
||||
return "guardian"
|
||||
if rset & set(role_tiers_cfg.get("charcoal", [])):
|
||||
return "charcoal"
|
||||
if rset & set(role_tiers_cfg.get("moderation", [])):
|
||||
return "moderation"
|
||||
if rset & set(role_tiers_cfg.get("citizen", [])):
|
||||
return "citizen"
|
||||
return "visitor"
|
||||
|
||||
def filter_tools_for_tier(tools: list, user_tier: str) -> list:
|
||||
user_lvl = TIER_LEVELS.get(user_tier, 0)
|
||||
enriched = []
|
||||
for t in tools:
|
||||
req_lvl = TIER_LEVELS.get(t.get("min_tier", "visitor"), 0)
|
||||
item = dict(t)
|
||||
item["unlocked"] = user_lvl >= req_lvl
|
||||
enriched.append(item)
|
||||
return enriched
|
||||
Loading…
Add table
Add a link
Reference in a new issue