Skip to content

Commit

Permalink
Merge pull request #2 from kitsteam/merge-upstream-0-0-1-2
Browse files Browse the repository at this point in the history
Merge upstream 0.0.1-2
  • Loading branch information
JannikStreek authored Feb 1, 2025
2 parents 114ca4a + e17079c commit bb14ad6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/utils/hooks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ describe("handleReadOnlyMode", () => {
expect(connectionConfiguration.readOnly).toBeTruthy();
});

it("should set readOnly mode to true when modificationSecret is set to readOnly", async () => {
const connectionConfiguration = buildConnectionConfiguration();

await handleReadOnlyMode(
prisma,
"documentName",
connectionConfiguration,
"readOnly",
);

expect(connectionConfiguration.readOnly).toBeTruthy();
});

it("should set readOnly mode to false when modificationSecret is valid", async () => {
const document = await createExampleDocument(prisma);

Expand Down
6 changes: 3 additions & 3 deletions src/utils/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const handleReadOnlyMode = async (
connection: ConnectionConfiguration,
token: string,
) => {
connection.readOnly = !(
token && (await isValidModificationSecret(prisma, documentName, token))
);
connection.readOnly =
token === "readOnly" ||
!(token && (await isValidModificationSecret(prisma, documentName, token)));
};

0 comments on commit bb14ad6

Please sign in to comment.