Compare commits

...

2 Commits

Author SHA1 Message Date
Tom Moor b309204b20 Record authType with createFromContext 2024-10-30 22:21:44 -04:00
Tom Moor 88ab604537 Add authType column to events 2024-10-30 19:04:26 -05:00
2 changed files with 23 additions and 7 deletions
@@ -0,0 +1,15 @@
"use strict";
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.addColumn("events", "authType", {
type: Sequelize.STRING,
allowNull: true,
});
},
async down(queryInterface) {
await queryInterface.removeColumn("events", "authType");
},
};
+8 -7
View File
@@ -18,7 +18,7 @@ import {
Length,
} from "sequelize-typescript";
import { globalEventQueue } from "../queues";
import { APIContext } from "../types";
import { APIContext, AuthenticationType } from "../types";
import Collection from "./Collection";
import Document from "./Document";
import Team from "./Team";
@@ -36,9 +36,7 @@ class Event extends IdModel<
@Column(DataType.UUID)
modelId: string | null;
/**
* The name of the event.
*/
/** The name of the event. */
@Length({
max: 255,
msg: "name must be 255 characters or less",
@@ -46,13 +44,15 @@ class Event extends IdModel<
@Column(DataType.STRING)
name: string;
/**
* The originating IP address of the event.
*/
/** The originating IP address of the event. */
@IsIP
@Column
ip: string | null;
/** The type of authentication used to create the event. */
@Column(DataType.ENUM(...Object.values(AuthenticationType)))
authType: AuthenticationType | null;
/**
* Metadata associated with the event, previously used for storing some changed attributes.
*/
@@ -171,6 +171,7 @@ class Event extends IdModel<
actorId: user.id,
teamId: user.teamId,
ip: ctx.request.ip,
authType: ctx.state.auth.type,
},
options
);