Cleanup 403 on websockets

This commit is contained in:
Zoe Roux
2026-04-28 23:38:43 +02:00
parent 0fea41cdd3
commit d31c96067c
2 changed files with 7 additions and 2 deletions
+6 -1
View File
@@ -92,7 +92,12 @@ export const appWs = baseWs.ws("/ws", {
const handler = actionMap[action as keyof typeof actionMap];
for (const perm of handler.permissions ?? []) {
if (!ws.data.jwt.permissions.includes(perm)) {
return ws.close(3000, `Missing permission: '${perm}'.`);
ws.send({
action: action,
status: 403,
message: `Missing permission: '${perm}'.`,
});
return;
}
}
await handler.message(ws as any, body as any);