mirror of
https://github.com/outline/outline.git
synced 2026-11-28 00:09:58 +03:00
fix: Missing ip on events created during account provisioning (#13334)
This commit is contained in:
1 parent
f65142989b
commit
97d74e84be
2 files changed
+39
-3
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import { faker } from "@faker-js/faker";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { errToString } from "@shared/utils/error";
|
||||
import { TeamDomain } from "@server/models";
|
||||
import { Event, TeamDomain } from "@server/models";
|
||||
import Collection from "@server/models/Collection";
|
||||
import UserAuthentication from "@server/models/UserAuthentication";
|
||||
import { buildUser, buildTeam, buildAdmin } from "@server/test/factories";
|
||||
@@ -57,6 +57,41 @@ describe("accountProvisioner", () => {
|
||||
expect(collectionCount).toEqual(1);
|
||||
});
|
||||
|
||||
it("should record the request ip on onboarding events", async () => {
|
||||
const { team } = await accountProvisioner(ctx, {
|
||||
user: {
|
||||
name: "Jenny Tester",
|
||||
email: faker.internet.email(),
|
||||
avatarUrl: faker.image.avatar(),
|
||||
},
|
||||
team: {
|
||||
name: "New workspace",
|
||||
avatarUrl: faker.image.avatar(),
|
||||
subdomain: faker.internet.domainWord(),
|
||||
},
|
||||
authenticationProvider: {
|
||||
name: "google",
|
||||
providerId: faker.internet.domainName(),
|
||||
},
|
||||
authentication: {
|
||||
providerId: randomUUID(),
|
||||
accessToken: "123",
|
||||
scopes: ["read"],
|
||||
},
|
||||
});
|
||||
|
||||
const events = await Event.findAll({
|
||||
where: {
|
||||
teamId: team.id,
|
||||
name: ["collections.create", "documents.create"],
|
||||
},
|
||||
});
|
||||
expect(events.length).toBeGreaterThan(0);
|
||||
events.forEach((event) => {
|
||||
expect(event.ip).toEqual(ip);
|
||||
});
|
||||
});
|
||||
|
||||
it("should update existing user and authentication", async () => {
|
||||
const existingTeam = await buildTeam();
|
||||
const providers = await existingTeam.$get("authenticationProviders");
|
||||
|
||||
@@ -285,9 +285,10 @@ async function provisionFirstCollection(
|
||||
) {
|
||||
await sequelize.transaction(async (transaction) => {
|
||||
const context = createContext({
|
||||
...ctx,
|
||||
transaction,
|
||||
user,
|
||||
authType: ctx.context.auth?.type,
|
||||
ip: ctx.context.ip,
|
||||
transaction,
|
||||
});
|
||||
|
||||
const collection = await Collection.createWithCtx(context, {
|
||||
|
||||
Reference in new issue
Block a user