Wire up chat permissions.
This commit is contained in:
parent
23235a7fe8
commit
627ede198b
2 changed files with 7 additions and 3 deletions
|
@ -143,6 +143,7 @@ PERMS = {
|
|||
"DEBUG_LOGIN_TO_OTHERS": 3,
|
||||
"CHAT_BYPASS_MUTE": 2,
|
||||
"CHAT_MODERATION": 2,
|
||||
"CHAT_FULL_CONTROL": 3,
|
||||
"PERFORMANCE_KILL_PROCESS": 3,
|
||||
"PERFORMANCE_SCALE_UP_DOWN": 3,
|
||||
"PERFORMANCE_RELOAD": 3,
|
||||
|
|
|
@ -18,10 +18,12 @@ def chat_is_allowed(perm_level: int=0):
|
|||
@functools.wraps(func)
|
||||
def wrapper(*args: Any, **kwargs: Any) -> bool | None:
|
||||
v = get_logged_in_user()
|
||||
# TODO: access control to specific small-groups
|
||||
if not v or v.is_suspended_permanently or v.admin_level < perm_level:
|
||||
return False
|
||||
return func(*args, v=v, **kwargs)
|
||||
return abort(403)
|
||||
if v.admin_level < PERMS['CHAT_FULL_CONTROL'] and not v.chat_authorized:
|
||||
return abort(403)
|
||||
kwargs['v'] = v
|
||||
return func(*args, **kwargs)
|
||||
return wrapper
|
||||
return wrapper_maker
|
||||
|
||||
|
@ -51,6 +53,7 @@ user_ids_to_socket_ids = {}
|
|||
|
||||
@app.get("/chat")
|
||||
@is_not_permabanned
|
||||
@chat_is_allowed()
|
||||
def chat(v):
|
||||
return render_template("chat.html", v=v, messages=messages)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue