mirror of
https://github.com/outline/outline.git
synced 2026-11-22 05:51:43 +03:00
feat: Attribute document creation to the auth type it was made with
This commit is contained in:
3 files changed
+13
-4
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { AuthenticationType } from "@shared/types";
|
||||
import { ProsemirrorHelper } from "@server/models/helpers/ProsemirrorHelper";
|
||||
import {
|
||||
buildUser,
|
||||
@@ -317,7 +318,10 @@ describe("documentCreator", () => {
|
||||
);
|
||||
|
||||
expect(document.importId).toBe(fileOperation.id);
|
||||
expect(document.sourceMetadata).toEqual(sourceMetadata);
|
||||
expect(document.sourceMetadata).toEqual({
|
||||
...sourceMetadata,
|
||||
authType: AuthenticationType.APP,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -173,10 +173,14 @@ export default async function documentCreator(
|
||||
lastModifiedById,
|
||||
}: Props
|
||||
): Promise<Document> {
|
||||
const { user } = ctx.state.auth;
|
||||
const { user, type: authType } = ctx.state.auth;
|
||||
const { transaction } = ctx.state;
|
||||
const templateId = template ? template.id : undefined;
|
||||
const eventData = importId || apiImportId ? { source: "import" } : undefined;
|
||||
// Note authType is applied last so that it always reflects the current
|
||||
// request, even when metadata is inherited from another document.
|
||||
const metadata =
|
||||
authType || sourceMetadata ? { ...sourceMetadata, authType } : null;
|
||||
|
||||
if (state && template) {
|
||||
throw new Error(
|
||||
@@ -227,7 +231,7 @@ export default async function documentCreator(
|
||||
publishedAt,
|
||||
importId,
|
||||
apiImportId,
|
||||
sourceMetadata,
|
||||
sourceMetadata: metadata,
|
||||
fullWidth: fullWidth ?? template?.fullWidth,
|
||||
icon: icon ?? template?.icon,
|
||||
color: color ?? template?.color,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { MentionType } from "@shared/types";
|
||||
import { AuthenticationType, MentionType } from "@shared/types";
|
||||
import { createContext } from "@server/context";
|
||||
import env from "@server/env";
|
||||
import { sequelize } from "@server/storage/database";
|
||||
@@ -163,6 +163,7 @@ describe("documentDuplicator", () => {
|
||||
fileName: "test.md",
|
||||
externalId: "ext123",
|
||||
originalDocumentId: original.id,
|
||||
authType: AuthenticationType.APP,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user