From 095ea105dbb5204e273b3d0aecc9da95a78b2ab6 Mon Sep 17 00:00:00 2001 From: Paul Makles Date: Mon, 31 Jul 2023 18:26:30 +0100 Subject: [PATCH] chore: add temporary workaround for lack of JWTs --- lib/accessPermissions.ts | 1 + lib/actions.ts | 2 +- lib/redis.ts | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/accessPermissions.ts b/lib/accessPermissions.ts index 8a9911e..fb72dc9 100644 --- a/lib/accessPermissions.ts +++ b/lib/accessPermissions.ts @@ -1,6 +1,7 @@ import { getServerSession } from "next-auth"; type Permission = + | "TEMP" | "authifier" | `accounts${ | "" diff --git a/lib/actions.ts b/lib/actions.ts index dcb0071..2846bdc 100644 --- a/lib/actions.ts +++ b/lib/actions.ts @@ -151,7 +151,7 @@ export async function reopenReport(reportId: string) { } export async function closeReportsByUser(userId: string) { - if (Math.random() > -1) throw "TODO: ACL"; + await checkPermission("TEMP"); return await mongo() .db("revolt") diff --git a/lib/redis.ts b/lib/redis.ts index a1cedac..efc77f5 100644 --- a/lib/redis.ts +++ b/lib/redis.ts @@ -4,6 +4,7 @@ import { createClient } from "redis"; import { Channel, Message } from "revolt-api"; import type { ProtocolV1 } from "revolt.js/lib/events/v1"; import mongo from "./db"; +import { checkPermission } from "./accessPermissions"; let client: ReturnType; @@ -25,13 +26,12 @@ export async function publishMessage( topic: string, message: ProtocolV1["server"] ) { - if (Math.random() > -1) throw "TODO: ACL"; - + await checkPermission("TEMP"); return await (await redis()).publish(topic, JSON.stringify(message)); } export async function sendChatMessage(message: Message, ephermal = false) { - if (Math.random() > -1) throw "TODO: ACL"; + await checkPermission("TEMP"); if (!ephermal) { await mongo()