From 073adbe48c6f9093879f64b4b945fbc90fa7dfd2 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 11 Jul 2023 11:19:01 +0200 Subject: [PATCH] do not allow to create room with self --- backend/src/schema/resolvers/rooms.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/src/schema/resolvers/rooms.ts b/backend/src/schema/resolvers/rooms.ts index 02309e172..293cd6e91 100644 --- a/backend/src/schema/resolvers/rooms.ts +++ b/backend/src/schema/resolvers/rooms.ts @@ -32,6 +32,9 @@ export default { const { user: { id: currentUserId }, } = context + if (userId === currentUserId) { + throw new Error('Cannot create a room with yourself') + } const session = context.driver.session() const writeTxResultPromise = session.writeTransaction(async (transaction) => { const createRoomCypher = `